summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWonguk Jeong <wonguk.jeong@samsung.com>2014-11-29 16:06:50 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2014-11-29 16:06:50 +0900
commit6de31e88b5b299dd1063419b2131402dc789d53e (patch)
tree5803d55539cbf2918f3d01fbee35e1fa5814aab8
parent65240b5327e5ab1eb8f77835b4729444fe1f02df (diff)
elm_cnp: decode escaped ASCII-encoded URI for dnd
Summary: encoded URI is pasted in terminology on dnd with file which has blank in name ex. Test Blank.avi -> Test%20Blank.avi Therefore, decode it when we extract file uris from uri list by using efreet. by the way, copy and paste code likely needs refactoring.. Reviewers: raster, cedric Subscribers: billiob, seoz Differential Revision: https://phab.enlightenment.org/D1384
-rw-r--r--src/lib/elm_cnp.c62
1 files changed, 49 insertions, 13 deletions
diff --git a/src/lib/elm_cnp.c b/src/lib/elm_cnp.c
index 0e98d8ee1..dcc484ba9 100644
--- a/src/lib/elm_cnp.c
+++ b/src/lib/elm_cnp.c
@@ -2,6 +2,7 @@
2# include "elementary_config.h" 2# include "elementary_config.h"
3#endif 3#endif
4#include <Elementary.h> 4#include <Elementary.h>
5#include <Efreet.h>
5#include "elm_priv.h" 6#include "elm_priv.h"
6#ifdef HAVE_MMAN_H 7#ifdef HAVE_MMAN_H
7# include <sys/mman.h> 8# include <sys/mman.h>
@@ -888,6 +889,7 @@ _x11_notify_handler_uri(X11_Cnp_Selection *sel, Ecore_X_Event_Selection_Notify *
888 if (data->content == ECORE_X_SELECTION_CONTENT_FILES) 889 if (data->content == ECORE_X_SELECTION_CONTENT_FILES)
889 { 890 {
890 int i, len = 0; 891 int i, len = 0;
892 Efreet_Uri **uri;
891 893
892 cnp_debug("got a files list\n"); 894 cnp_debug("got a files list\n");
893 files = notify->data; 895 files = notify->data;
@@ -900,11 +902,29 @@ _x11_notify_handler_uri(X11_Cnp_Selection *sel, Ecore_X_Event_Selection_Notify *
900 } 902 }
901 stripstr = p = strdup(files->files[0]); 903 stripstr = p = strdup(files->files[0]);
902 */ 904 */
905
906 uri = calloc(1, sizeof(*uri) * files->num_files);
907 if (!uri) return 0;
908
903 for (i = 0; i < files->num_files ; i++) 909 for (i = 0; i < files->num_files ; i++)
904 { 910 {
905 p = files->files[i]; 911 uri[i] = efreet_uri_decode(files->files[i]);
906 if ((strncmp(p, "file:/", 6)) && (p[0] != '/')) continue; 912 if (!uri[i])
907 len += strlen(files->files[i]) + 1; 913 {
914 /* Is there any reason why we care of URI without scheme? */
915 if (files->files[i][0] != '/') continue;
916 len += strlen(files->files[i]) + 1;
917 }
918 else
919 {
920 if (strcmp(uri[i]->protocol, "file"))
921 {
922 efreet_uri_free(uri[i]);
923 uri[i] = NULL;
924 continue;
925 }
926 len += strlen(uri[i]->path) + 1;
927 }
908 } 928 }
909 p = NULL; 929 p = NULL;
910 if (len > 0) 930 if (len > 0)
@@ -912,9 +932,11 @@ _x11_notify_handler_uri(X11_Cnp_Selection *sel, Ecore_X_Event_Selection_Notify *
912 s = stripstr = malloc(len + 1); 932 s = stripstr = malloc(len + 1);
913 for (i = 0; i < files->num_files ; i++) 933 for (i = 0; i < files->num_files ; i++)
914 { 934 {
915 p = files->files[i]; 935 if (uri[i])
916 if (!strncmp(p, "file:/", 6)) p += 5; 936 p = (char *)uri[i]->path;
917 else if (p[0] != '/') continue; 937 else
938 p = files->files[i];
939
918 len = strlen(p); 940 len = strlen(p);
919 strcpy(s, p); 941 strcpy(s, p);
920 if (i < (files->num_files - 1)) 942 if (i < (files->num_files - 1))
@@ -928,26 +950,40 @@ _x11_notify_handler_uri(X11_Cnp_Selection *sel, Ecore_X_Event_Selection_Notify *
928 s[len] = 0; 950 s[len] = 0;
929 s += len; 951 s += len;
930 } 952 }
953
954 if (uri[i])
955 efreet_uri_free(uri[i]);
931 } 956 }
932 } 957 }
958 free(uri);
933 } 959 }
934 else 960 else
935 { 961 {
962 Efreet_Uri *uri;
963 int len = 0;
964
936 p = (char *)data->data; 965 p = (char *)data->data;
937 if ((!strncmp(p, "file:/", 6)) || (p[0] == '/')) 966 uri = efreet_uri_decode(p);
967 if (!uri)
968 {
969 /* Is there any reason why we care of URI without scheme? */
970 if (p[0] == '/')
971 len = data->length;
972 }
973 else
974 {
975 p = (char *)uri->path;
976 len = strlen(p);
977 }
978 if (len > 0)
938 { 979 {
939 int len = data->length;
940 if (!strncmp(p, "file:/", 6))
941 {
942 p += 5;
943 len -= 5;
944 }
945 stripstr = malloc(len + 1); 980 stripstr = malloc(len + 1);
946 if (!stripstr) return 0; 981 if (!stripstr) return 0;
947 memcpy(stripstr, p, len); 982 memcpy(stripstr, p, len);
948 stripstr[len] = 0; 983 stripstr[len] = 0;
949 } 984 }
950 } 985 }
986
951 if (!stripstr) 987 if (!stripstr)
952 { 988 {
953 cnp_debug("Couldn't find a file\n"); 989 cnp_debug("Couldn't find a file\n");