escape filenames for terminology helpers.

This commit is contained in:
Carsten Haitzler 2013-04-19 00:19:21 +09:00
parent 5ea38eeeb1
commit 1f1fcf2dd2
2 changed files with 87 additions and 73 deletions

1
TODO
View File

@ -31,7 +31,6 @@ make it a first-class terminal:
[ ] number recognition with base (hex/dec/oct/binary etc.) conversion [ ] number recognition with base (hex/dec/oct/binary etc.) conversion
[ ] dnd of file to term offer to paste path, with escapes or paste file [ ] dnd of file to term offer to paste path, with escapes or paste file
content (if text) with or without escaping 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 [ ] media - improve position slider to track position as u play
[ ] improve look of meida controls (youtube like better with mouse move show) [ ] improve look of meida controls (youtube like better with mouse move show)
[ ] make media controls an api where controls are provided by the media [ ] make media controls an api where controls are provided by the media

View File

@ -122,7 +122,7 @@ _activate_link(Evas_Object *obj)
{ {
Termio *sd = evas_object_smart_data_get(obj); Termio *sd = evas_object_smart_data_get(obj);
Config *config = termio_config_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; const char *path = NULL, *cmd = NULL;
Eina_Bool url = EINA_FALSE, email = EINA_FALSE, handled = EINA_FALSE; Eina_Bool url = EINA_FALSE, email = EINA_FALSE, handled = EINA_FALSE;
int type; int type;
@ -165,101 +165,116 @@ _activate_link(Evas_Object *obj)
if (casestartswith(s, "mailto:")) if (casestartswith(s, "mailto:"))
p += sizeof("mailto:") - 1; 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) else if (path)
{ {
// locally accessible file // locally accessible file
cmd = "xdg-open"; cmd = "xdg-open";
type = media_src_type_get(sd->link.string); escaped = ecore_file_escape_name(s);
if (_should_inline(obj)) if (escaped)
{ {
if ((type == TYPE_IMG) || type = media_src_type_get(sd->link.string);
(type == TYPE_SCALE) || if (_should_inline(obj))
(type == TYPE_EDJE))
{ {
evas_object_smart_callback_call(obj, "popup", NULL); if ((type == TYPE_IMG) ||
handled = EINA_TRUE; (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 (type == TYPE_MOV) if (!handled)
{ {
evas_object_smart_callback_call(obj, "popup", NULL); if ((type == TYPE_IMG) ||
handled = EINA_TRUE; (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);
} }
} }
if (!handled)
{
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, s);
}
} }
else if (url) else if (url)
{ {
// remote file needs ecore-con-url // remote file needs ecore-con-url
cmd = "xdg-open"; cmd = "xdg-open";
type = media_src_type_get(sd->link.string); escaped = ecore_file_escape_name(s);
if (_should_inline(obj)) if (escaped)
{ {
if ((type == TYPE_IMG) || type = media_src_type_get(sd->link.string);
(type == TYPE_SCALE) || if (_should_inline(obj))
(type == TYPE_EDJE))
{ {
// XXX: begin fetch of url, once done, show if ((type == TYPE_IMG) ||
evas_object_smart_callback_call(obj, "popup", NULL); (type == TYPE_SCALE) ||
handled = EINA_TRUE; (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 (type == TYPE_MOV) if (!handled)
{ {
// XXX: if no http:// add if ((type == TYPE_IMG) ||
evas_object_smart_callback_call(obj, "popup", NULL); (type == TYPE_SCALE) ||
handled = EINA_TRUE; (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);
} }
} }
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;
}
else
{
if ((config->helper.url.general) &&
(config->helper.url.general[0]))
cmd = config->helper.url.general;
}
snprintf(buf, sizeof(buf), "%s %s", cmd, s);
}
} }
else else
{ {