summaryrefslogtreecommitdiff
path: root/src
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 /src
parentcf58c1ee76582a4465cf282426b591dcab349e51 (diff)
trim selection before trying to open it as url
Diffstat (limited to 'src')
-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)
4043{ 4043{
4044 Evas_Object *term = data; 4044 Evas_Object *term = data;
4045 Termio *sd = evas_object_smart_data_get(term); 4045 Termio *sd = evas_object_smart_data_get(term);
4046 char buf[PATH_MAX], *s, *escaped; 4046 char buf[PATH_MAX], *s = NULL, *escaped = NULL;
4047 const char *cmd; 4047 const char *cmd;
4048 const char *prefix = "http://"; 4048 const char *prefix = "http://";
4049 Config *config; 4049 Config *config;
4050 Eina_Strbuf *sb = NULL;
4050 4051
4051 EINA_SAFETY_ON_NULL_RETURN(sd); 4052 EINA_SAFETY_ON_NULL_RETURN(sd);
4052 config = sd->config; 4053 config = sd->config;
@@ -4061,7 +4062,13 @@ _cb_ctxp_sel_open_as_url(void *data, Evas_Object *obj, void *event EINA_UNUSED)
4061 goto end; 4062 goto end;
4062 cmd = config->helper.url.general; 4063 cmd = config->helper.url.general;
4063 4064
4064 s = eina_str_escape(sd->sel_str); 4065 sb = eina_strbuf_new();
4066 if (!sb)
4067 goto end;
4068 eina_strbuf_append(sb, sd->sel_str);
4069 eina_strbuf_trim(sb);
4070
4071 s = eina_str_escape(eina_strbuf_string_get(sb));
4065 if (!s) 4072 if (!s)
4066 goto end; 4073 goto end;
4067 if (casestartswith(s, "http://") || 4074 if (casestartswith(s, "http://") ||
@@ -4075,12 +4082,14 @@ _cb_ctxp_sel_open_as_url(void *data, Evas_Object *obj, void *event EINA_UNUSED)
4075 goto end; 4082 goto end;
4076 4083
4077 snprintf(buf, sizeof(buf), "%s %s%s", cmd, prefix, escaped); 4084 snprintf(buf, sizeof(buf), "%s %s%s", cmd, prefix, escaped);
4078 free(escaped);
4079 4085
4080 WRN("trying to launch '%s'", buf); 4086 WRN("trying to launch '%s'", buf);
4081 ecore_exe_run(buf, NULL); 4087 ecore_exe_run(buf, NULL);
4082 4088
4083end: 4089end:
4090 eina_strbuf_free(sb);
4091 free(escaped);
4092 free(s);
4084 sd->ctxpopup = NULL; 4093 sd->ctxpopup = NULL;
4085 evas_object_del(obj); 4094 evas_object_del(obj);
4086} 4095}