netstar pushed a commit to branch master.

http://git.enlightenment.org/tools/edi.git/commit/?id=e86760b802ace859ec9c29c8d4fcaf1a0d849d54

commit e86760b802ace859ec9c29c8d4fcaf1a0d849d54
Author: Al Poole <[email protected]>
Date:   Wed Sep 27 19:42:45 2017 +0100

    edi: escape paths where necessary.
---
 src/bin/edi_filepanel.c            |  8 +++--
 src/bin/screens/edi_file_screens.c | 20 ++++++++---
 src/lib/edi_scm.c                  | 68 ++++++++++++++++++++++++++++++--------
 src/lib/edi_scm.h                  |  1 +
 4 files changed, 76 insertions(+), 21 deletions(-)

diff --git a/src/bin/edi_filepanel.c b/src/bin/edi_filepanel.c
index 7ad0f7c..bd5f6f6 100644
--- a/src/bin/edi_filepanel.c
+++ b/src/bin/edi_filepanel.c
@@ -184,6 +184,7 @@ edi_filepanel_scm_status_update(void)
              _file_status_item_add(status->fullpath, status->change);
              eina_stringshare_del(status->path);
              eina_stringshare_del(status->fullpath);
+             eina_stringshare_del(status->unescaped);
              free(status);
           }
         eina_list_free(e->statuses);
@@ -609,7 +610,7 @@ _content_get(void *data, Evas_Object *obj, const char 
*source)
    Edi_Dir_Data *sd = data;
    Evas_Object *box, *lbox, *mbox, *rbox, *label, *ic;
    Edi_Scm_Status_Code *code;
-   char *text;
+   char *text, *escaped;
    const char *icon_name, *icon_status;
    Eina_Bool staged = EINA_FALSE;
 
@@ -618,10 +619,13 @@ _content_get(void *data, Evas_Object *obj, const char 
*source)
 
    text = NULL; icon_name = icon_status = NULL;
 
-   code = _file_status_item_find(sd->path);
+   escaped = ecore_file_escape_name(sd->path);
+   code = _file_status_item_find(escaped);
    if (code)
      icon_status = _icon_status(*code, &staged);
 
+   free(escaped);
+
    text = strdup(basename((char *)sd->path));
 
    provider = _get_provider_from_hashset(sd->path);
diff --git a/src/bin/screens/edi_file_screens.c 
b/src/bin/screens/edi_file_screens.c
index ebe18a6..5e9233f 100644
--- a/src/bin/screens/edi_file_screens.c
+++ b/src/bin/screens/edi_file_screens.c
@@ -49,6 +49,7 @@ _edi_file_screens_create_file_cb(void *data,
                              void *event_info EINA_UNUSED)
 {
    const char *name;
+   char *text;
    char *path;
    const char *directory = _directory_path;
    FILE *f;
@@ -63,7 +64,9 @@ _edi_file_screens_create_file_cb(void *data,
         return;
      }
 
-   path = edi_path_append(directory, name);
+   text = elm_entry_markup_to_utf8(name);
+
+   path = edi_path_append(directory, text);
    if ((ecore_file_exists(path) && ecore_file_is_dir(path)) ||
        !ecore_file_exists(path))
      {
@@ -82,6 +85,7 @@ _edi_file_screens_create_file_cb(void *data,
 
    evas_object_del(_popup);
    free(path);
+   free(text);
 }
 
 static void
@@ -90,7 +94,7 @@ _edi_file_screens_create_dir_cb(void *data,
                              void *event_info EINA_UNUSED)
 {
    const char *name;
-   char *path;
+   char *path, *text;
    const char *directory = _directory_path;
 
    if (!ecore_file_is_dir(directory)) return;
@@ -102,7 +106,9 @@ _edi_file_screens_create_dir_cb(void *data,
         return;
      }
 
-   path = edi_path_append(directory, name);
+   text = elm_entry_markup_to_utf8(name);
+
+   path = edi_path_append(directory, text);
 
    mkdir(path, 0755);
 
@@ -111,6 +117,7 @@ _edi_file_screens_create_dir_cb(void *data,
 
    evas_object_del(_popup_dir);
    free(path);
+   free(text);
 }
 
 static void
@@ -120,7 +127,7 @@ _edi_file_screens_rename_cb(void *data,
 {
    Evas_Object *entry;
    const char *name, *existing_path, *directory;
-   char *path;
+   char *path, *text;
 
    directory = _directory_path;
    existing_path = (char *) data;
@@ -134,7 +141,9 @@ _edi_file_screens_rename_cb(void *data,
         return;
      }
 
-   path = edi_path_append(directory, name);
+   text = elm_entry_markup_to_utf8(name);
+
+   path = edi_path_append(directory, text);
 
    if (ecore_file_exists(path))
      {
@@ -161,6 +170,7 @@ _edi_file_screens_rename_cb(void *data,
 
    evas_object_del(_popup);
    free(path);
+   free(text);
 }
 
 void
diff --git a/src/lib/edi_scm.c b/src/lib/edi_scm.c
index 56bea4b..466dd44 100644
--- a/src/lib/edi_scm.c
+++ b/src/lib/edi_scm.c
@@ -91,7 +91,7 @@ _edi_scm_git_file_add(const char *path)
    int code;
    Eina_Strbuf *command = eina_strbuf_new();
 
-   eina_strbuf_append_printf(command, "git add '%s'", path);
+   eina_strbuf_append_printf(command, "git add %s", path);
 
    code = _edi_scm_exec(eina_strbuf_string_get(command));
 
@@ -106,7 +106,7 @@ _edi_scm_git_file_mod(const char *path)
    int code;
    Eina_Strbuf *command = eina_strbuf_new();
 
-   eina_strbuf_append_printf(command, "git mod '%s'", path);
+   eina_strbuf_append_printf(command, "git mod %s", path);
 
    code = _edi_scm_exec(eina_strbuf_string_get(command));
 
@@ -136,7 +136,7 @@ _edi_scm_git_file_del(const char *path)
    int code;
    Eina_Strbuf *command = eina_strbuf_new();
 
-   eina_strbuf_append_printf(command, "git rm '%s'", path);
+   eina_strbuf_append_printf(command, "git rm %s", path);
 
    code = _edi_scm_exec(eina_strbuf_string_get(command));
 
@@ -163,7 +163,7 @@ _edi_scm_git_status(void)
 static Edi_Scm_Status *
 _parse_line(char *line)
 {
-   char *path, *fullpath, *change;
+   char *esc_path, *path, *fullpath, *change;
    Edi_Scm_Status *status;
 
    change = line;
@@ -215,10 +215,14 @@ _parse_line(char *line)
    else
         status->change = EDI_SCM_STATUS_UNKNOWN;
 
-   status->path = eina_stringshare_add(path);
-   fullpath = edi_path_append(edi_project_get(), path);
+   esc_path = ecore_file_escape_name(path);
+   status->path = eina_stringshare_add(esc_path);
+   fullpath = edi_path_append(edi_project_get(), esc_path);
    status->fullpath = eina_stringshare_add(fullpath);
+   status->unescaped = eina_stringshare_add(path);
+
    free(fullpath);
+   free(esc_path);
 
    return status;
 }
@@ -228,11 +232,12 @@ _edi_scm_git_file_status(const char *path)
 {
    Edi_Scm_Status *status;
    char command[4096];
-   char *line;
+   char *line, *escaped;
    Edi_Scm_Status_Code result;
 
-   snprintf(command, sizeof(command), "git status --porcelain '%s'", path);
-
+   escaped = ecore_file_escape_name(path);
+   snprintf(command, sizeof(command), "git status --porcelain %s", escaped);
+   free(escaped);
    line = _edi_scm_exec_response(command);
    if (!line[0] || !line[1])
      {
@@ -244,6 +249,7 @@ _edi_scm_git_file_status(const char *path)
         result = status->change;
         eina_stringshare_del(status->path);
         eina_stringshare_del(status->fullpath);
+        eina_stringshare_del(status->unescaped);
         free(status);
      }
 
@@ -342,7 +348,7 @@ _edi_scm_git_commit(const char *message)
    int code;
    Eina_Strbuf *command = eina_strbuf_new();
 
-   eina_strbuf_append_printf(command, "git commit -m '%s'", message);
+   eina_strbuf_append_printf(command, "git commit -m \"%s\"", message);
 
    code = _edi_scm_exec(eina_strbuf_string_get(command));
 
@@ -534,25 +540,51 @@ edi_scm_shutdown()
 EAPI int
 edi_scm_add(const char *path)
 {
+   char *escaped;
+   int result;
    Edi_Scm_Engine *e = edi_scm_engine_get();
 
-   return e->file_add(path);
+   escaped = ecore_file_escape_name(path);
+
+   result = e->file_add(escaped);
+
+   free(escaped);
+
+   return result;
 }
 
 EAPI int
 edi_scm_del(const char *path)
 {
+   char *escaped;
+   int result;
    Edi_Scm_Engine *e = edi_scm_engine_get();
 
-   return e->file_del(path);
+   escaped = ecore_file_escape_name(path);
+
+   result = e->file_del(escaped);
+
+   free(escaped);
+
+   return result;
 }
 
 EAPI int
 edi_scm_move(const char *src, const char *dest)
 {
+   char *esc_src, *esc_dst;
+   int result;
    Edi_Scm_Engine *e = edi_scm_engine_get();
 
-   return e->move(src, dest);
+   esc_src = ecore_file_escape_name(src);
+   esc_dst = ecore_file_escape_name(dest);
+
+   result = e->move(esc_src, esc_dst);
+
+   free(esc_src);
+   free(esc_dst);
+
+   return result;
 }
 
 EAPI Eina_Bool
@@ -571,9 +603,17 @@ edi_scm_status_get(void)
 EAPI Edi_Scm_Status_Code
 edi_scm_file_status(const char *path)
 {
+   char *escaped;
+   int result;
    Edi_Scm_Engine *e = edi_scm_engine_get();
 
-   return e->file_status(path);
+   escaped = ecore_file_escape_name(path);
+
+   result = e->file_status(escaped);
+
+   free(escaped);
+
+   return result;
 }
 
 EAPI void
diff --git a/src/lib/edi_scm.h b/src/lib/edi_scm.h
index 480b762..0f14865 100644
--- a/src/lib/edi_scm.h
+++ b/src/lib/edi_scm.h
@@ -28,6 +28,7 @@ typedef struct _Edi_Scm_Status
 {
    Eina_Stringshare *path;
    Eina_Stringshare *fullpath;
+   Eina_Stringshare *unescaped;
    Edi_Scm_Status_Code change;
    Eina_Bool staged;
 } Edi_Scm_Status;

-- 


Reply via email to