raster pushed a commit to branch master.
commit 1f1fcf2dd20a49762557ddf2afc602f378de45e4
Author: Carsten Haitzler (Rasterman) <[email protected]>
Date: Fri Apr 19 00:19:21 2013 +0900
escape filenames for terminology helpers.
---
TODO | 1 -
src/bin/termio.c | 159 ++++++++++++++++++++++++++++++-------------------------
2 files changed, 87 insertions(+), 73 deletions(-)
diff --git a/TODO b/TODO
index 5638b5f..d0b925a 100644
--- a/TODO
+++ b/TODO
@@ -31,7 +31,6 @@ make it a first-class terminal:
[ ] number recognition with base (hex/dec/oct/binary etc.) conversion
[ ] dnd of file to term offer to paste path, with escapes or paste file
content (if text) with or without escaping
-[ ] helpers when executed need to escape path/uri in command buffer
[ ] media - improve position slider to track position as u play
[ ] improve look of meida controls (youtube like better with mouse move show)
[ ] make media controls an api where controls are provided by the media
diff --git a/src/bin/termio.c b/src/bin/termio.c
index db4af00..7dd32af 100644
--- a/src/bin/termio.c
+++ b/src/bin/termio.c
@@ -122,7 +122,7 @@ _activate_link(Evas_Object *obj)
{
Termio *sd = evas_object_smart_data_get(obj);
Config *config = termio_config_get(obj);
- char buf[PATH_MAX], *s;
+ char buf[PATH_MAX], *s, *escaped;
const char *path = NULL, *cmd = NULL;
Eina_Bool url = EINA_FALSE, email = EINA_FALSE, handled = EINA_FALSE;
int type;
@@ -165,52 +165,62 @@ _activate_link(Evas_Object *obj)
if (casestartswith(s, "mailto:"))
p += sizeof("mailto:") - 1;
- snprintf(buf, sizeof(buf), "%s %s", cmd, p);
+ escaped = ecore_file_escape_name(p);
+ if (escaped)
+ {
+ snprintf(buf, sizeof(buf), "%s %s", cmd, escaped);
+ free(escaped);
+ }
}
else if (path)
{
// locally accessible file
cmd = "xdg-open";
- type = media_src_type_get(sd->link.string);
- if (_should_inline(obj))
- {
- if ((type == TYPE_IMG) ||
- (type == TYPE_SCALE) ||
- (type == TYPE_EDJE))
- {
- evas_object_smart_callback_call(obj, "popup", NULL);
- handled = EINA_TRUE;
- }
- else if (type == TYPE_MOV)
- {
- evas_object_smart_callback_call(obj, "popup", NULL);
- handled = EINA_TRUE;
- }
- }
- if (!handled)
+ escaped = ecore_file_escape_name(s);
+ if (escaped)
{
- if ((type == TYPE_IMG) ||
- (type == TYPE_SCALE) ||
- (type == TYPE_EDJE))
- {
- if ((config->helper.local.image) &&
- (config->helper.local.image[0]))
- cmd = config->helper.local.image;
- }
- else if (type == TYPE_MOV)
+ type = media_src_type_get(sd->link.string);
+ if (_should_inline(obj))
{
- if ((config->helper.local.video) &&
- (config->helper.local.video[0]))
- cmd = config->helper.local.video;
+ if ((type == TYPE_IMG) ||
+ (type == TYPE_SCALE) ||
+ (type == TYPE_EDJE))
+ {
+ evas_object_smart_callback_call(obj, "popup", NULL);
+ handled = EINA_TRUE;
+ }
+ else if (type == TYPE_MOV)
+ {
+ evas_object_smart_callback_call(obj, "popup", NULL);
+ handled = EINA_TRUE;
+ }
}
- else
+ if (!handled)
{
- if ((config->helper.local.general) &&
- (config->helper.local.general[0]))
- cmd = config->helper.local.general;
+ if ((type == TYPE_IMG) ||
+ (type == TYPE_SCALE) ||
+ (type == TYPE_EDJE))
+ {
+ if ((config->helper.local.image) &&
+ (config->helper.local.image[0]))
+ cmd = config->helper.local.image;
+ }
+ else if (type == TYPE_MOV)
+ {
+ if ((config->helper.local.video) &&
+ (config->helper.local.video[0]))
+ cmd = config->helper.local.video;
+ }
+ else
+ {
+ if ((config->helper.local.general) &&
+ (config->helper.local.general[0]))
+ cmd = config->helper.local.general;
+ }
+ snprintf(buf, sizeof(buf), "%s %s", cmd, escaped);
+ free(escaped);
}
- snprintf(buf, sizeof(buf), "%s %s", cmd, s);
}
}
else if (url)
@@ -218,47 +228,52 @@ _activate_link(Evas_Object *obj)
// remote file needs ecore-con-url
cmd = "xdg-open";
- type = media_src_type_get(sd->link.string);
- if (_should_inline(obj))
+ escaped = ecore_file_escape_name(s);
+ if (escaped)
{
- if ((type == TYPE_IMG) ||
- (type == TYPE_SCALE) ||
- (type == TYPE_EDJE))
- {
- // XXX: begin fetch of url, once done, show
- evas_object_smart_callback_call(obj, "popup", NULL);
- handled = EINA_TRUE;
- }
- else if (type == TYPE_MOV)
+ type = media_src_type_get(sd->link.string);
+ if (_should_inline(obj))
{
- // XXX: if no http:// add
- evas_object_smart_callback_call(obj, "popup", NULL);
- handled = EINA_TRUE;
- }
- }
- if (!handled)
- {
- if ((type == TYPE_IMG) ||
- (type == TYPE_SCALE) ||
- (type == TYPE_EDJE))
- {
- if ((config->helper.url.image) &&
- (config->helper.url.image[0]))
- cmd = config->helper.url.image;
- }
- else if (type == TYPE_MOV)
- {
- if ((config->helper.url.video) &&
- (config->helper.url.video[0]))
- cmd = config->helper.url.video;
+ if ((type == TYPE_IMG) ||
+ (type == TYPE_SCALE) ||
+ (type == TYPE_EDJE))
+ {
+ // XXX: begin fetch of url, once done, show
+ evas_object_smart_callback_call(obj, "popup", NULL);
+ handled = EINA_TRUE;
+ }
+ else if (type == TYPE_MOV)
+ {
+ // XXX: if no http:// add
+ evas_object_smart_callback_call(obj, "popup", NULL);
+ handled = EINA_TRUE;
+ }
}
- else
+ if (!handled)
{
- if ((config->helper.url.general) &&
- (config->helper.url.general[0]))
- cmd = config->helper.url.general;
+ if ((type == TYPE_IMG) ||
+ (type == TYPE_SCALE) ||
+ (type == TYPE_EDJE))
+ {
+ if ((config->helper.url.image) &&
+ (config->helper.url.image[0]))
+ cmd = config->helper.url.image;
+ }
+ else if (type == TYPE_MOV)
+ {
+ if ((config->helper.url.video) &&
+ (config->helper.url.video[0]))
+ cmd = config->helper.url.video;
+ }
+ else
+ {
+ if ((config->helper.url.general) &&
+ (config->helper.url.general[0]))
+ cmd = config->helper.url.general;
+ }
+ snprintf(buf, sizeof(buf), "%s %s", cmd, escaped);
+ free(escaped);
}
- snprintf(buf, sizeof(buf), "%s %s", cmd, s);
}
}
else
--
------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter