aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBoris Faure <billiob@gmail.com>2015-08-24 23:45:14 +0200
committerBoris Faure <billiob@gmail.com>2015-08-24 23:45:14 +0200
commit45b7d204256520210489bd9708091792d120470c (patch)
tree50943a278624583ecbf31d0720a7b2328981ee44
parentadd context menu to open a selection as an url. Closes T584 (diff)
downloadterminology-45b7d204256520210489bd9708091792d120470c.tar.gz
trim selection before trying to open it as url
-rw-r--r--src/bin/termio.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/bin/termio.c b/src/bin/termio.c
index f9300e3..42f5502 100644
--- a/src/bin/termio.c
+++ b/src/bin/termio.c
@@ -4043,10 +4043,11 @@ _cb_ctxp_sel_open_as_url(void *data, Evas_Object *obj, void *event EINA_UNUSED)
{
Evas_Object *term = data;
Termio *sd = evas_object_smart_data_get(term);
- char buf[PATH_MAX], *s, *escaped;
+ char buf[PATH_MAX], *s = NULL, *escaped = NULL;
const char *cmd;
const char *prefix = "http://";
Config *config;
+ Eina_Strbuf *sb = NULL;
EINA_SAFETY_ON_NULL_RETURN(sd);
config = sd->config;
@@ -4061,7 +4062,13 @@ _cb_ctxp_sel_open_as_url(void *data, Evas_Object *obj, void *event EINA_UNUSED)
goto end;
cmd = config->helper.url.general;
- s = eina_str_escape(sd->sel_str);
+ sb = eina_strbuf_new();
+ if (!sb)
+ goto end;
+ eina_strbuf_append(sb, sd->sel_str);
+ eina_strbuf_trim(sb);
+
+ s = eina_str_escape(eina_strbuf_string_get(sb));
if (!s)
goto end;
if (casestartswith(s, "http://") ||
@@ -4075,12 +4082,14 @@ _cb_ctxp_sel_open_as_url(void *data, Evas_Object *obj, void *event EINA_UNUSED)
goto end;
snprintf(buf, sizeof(buf), "%s %s%s", cmd, prefix, escaped);
- free(escaped);
WRN("trying to launch '%s'", buf);
ecore_exe_run(buf, NULL);
end:
+ eina_strbuf_free(sb);
+ free(escaped);
+ free(s);
sd->ctxpopup = NULL;
evas_object_del(obj);
}