Enlightenment CVS committal
Author : raster
Project : e17
Module : apps/e
Dir : e17/apps/e/src/bin
Modified Files:
e_apps.c e_utils.c e_utils.h
Log Message:
handle spaces in eap filenames when editing, and proeprly escape things, add
gneric escaper, and reduce file path of icon files nicely.
===================================================================
RCS file: /cvs/e/e17/apps/e/src/bin/e_apps.c,v
retrieving revision 1.132
retrieving revision 1.133
diff -u -3 -r1.132 -r1.133
--- e_apps.c 13 May 2006 14:57:20 -0000 1.132
+++ e_apps.c 13 May 2006 15:20:15 -0000 1.133
@@ -1419,7 +1419,7 @@
static int
_e_app_new_save(E_App *a)
{
- static char tmpn[1024];
+ static char tmpn[4096];
int fd = 0, ret = 0;
char cmd[2048];
char ipart[512];
@@ -1446,20 +1446,13 @@
}
i = 0;
-
if (a->image)
{
start = strchr(a->image, '/');
- end = strrchr(a->image ,'/');
+ end = strrchr(a->image, '/');
- if (start == end)
- {
- imgdir = strdup("/");;
- }
- else if ((!start) || (!end))
- {
- imgdir = strdup("");
- }
+ if (start == end) imgdir = strdup("/");
+ else if ((!start) || (!end)) imgdir = strdup("");
else
{
imgdir = malloc((end - start + 1));
@@ -1473,24 +1466,27 @@
if (imgdir)
{
- snprintf(ipart, sizeof(ipart), "-id %s", imgdir);
+ snprintf(ipart, sizeof(ipart), "-id %s",
+ e_util_filename_escape(imgdir));
free(imgdir);
}
- else ipart[0] = '\0';
+ else ipart[0] = 0;
if (a->image)
{
- if (a->width <= 0)
- a->width = EAP_MIN_WIDTH;
- if (a->height <= 0)
- a->height = EAP_MIN_HEIGHT;
- fprintf(out, EAP_EDC_TMPL, a->image, a->width, a->height, a->image);
+ if (a->width <= 0) a->width = EAP_MIN_WIDTH;
+ if (a->height <= 0) a->height = EAP_MIN_HEIGHT;
+ fprintf(out, EAP_EDC_TMPL,
+ e_util_filename_escape(ecore_file_get_file(a->image)),
+ a->width, a->height,
+ e_util_filename_escape(ecore_file_get_file(a->image)));
}
else
fprintf(out, EAP_EDC_TMPL_EMPTY);
fclose(out);
- snprintf(cmd, sizeof(cmd), "edje_cc -v %s %s %s", ipart, tmpn, a->path);
+ snprintf(cmd, sizeof(cmd), "edje_cc -v %s %s %s", ipart, tmpn,
+ e_util_filename_escape(a->path));
ret = system(cmd);
if (ret < 0)
@@ -1500,7 +1496,7 @@
return 0;
}
- unlink(tmpn);
+ ecore_file_unlink(tmpn);
return 1;
}
===================================================================
RCS file: /cvs/e/e17/apps/e/src/bin/e_utils.c,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -3 -r1.41 -r1.42
--- e_utils.c 30 Apr 2006 04:31:42 -0000 1.41
+++ e_utils.c 13 May 2006 15:20:15 -0000 1.42
@@ -527,6 +527,38 @@
e_dialog_show(dia);
}
+EAPI const char *
+e_util_filename_escape(const char *filename)
+{
+ char *p, *q;
+ static char buf[4096];
+
+ p = filename;
+ q = buf;
+ while (*p)
+ {
+ if ((q - buf) > 4090) return NULL;
+ if (
+ (*p == ' ') || (*p == '\t') || (*p == '\n') ||
+ (*p == '\\') || (*p == '\'') || (*p == '\"') ||
+ (*p == ';') || (*p == '!') || (*p == '#') ||
+ (*p == '$') || (*p == '%') || (*p == '&') ||
+ (*p == '*') || (*p == '(') || (*p == ')') ||
+ (*p == '[') || (*p == ']') || (*p == '{') ||
+ (*p == '}') || (*p == '|') || (*p == '<') ||
+ (*p == '>') || (*p == '?')
+ )
+ {
+ *q = '\\';
+ q++;
+ }
+ *q = *p;
+ q++;
+ p++;
+ }
+ return buf;
+}
+
/* local subsystem functions */
static void
_e_util_container_fake_mouse_up_cb(void *data)
===================================================================
RCS file: /cvs/e/e17/apps/e/src/bin/e_utils.h,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -3 -r1.22 -r1.23
--- e_utils.h 2 Mar 2006 12:03:48 -0000 1.22
+++ e_utils.h 13 May 2006 15:20:15 -0000 1.23
@@ -39,6 +39,7 @@
EAPI E_Border *e_util_desk_border_below(E_Border *bd);
EAPI int e_util_edje_collection_exists(const char *file, const char
*coll);
EAPI void e_util_dialog_internal(const char *title, const char *txt);
-
+EAPI const char *e_util_filename_escape(const char *filename);
+
#endif
#endif
-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
enlightenment-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs