summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Hacohen <tom@stosb.com>2014-01-27 15:14:32 +0000
committerTom Hacohen <tom@stosb.com>2014-01-27 15:17:31 +0000
commit2d4ba9e8dd0fb335ce30bce4425d273db5d6f7e7 (patch)
tree698dc867596988883b6785fa14425158972a7013 /src
parent325bf9ab78a9d8d35d5c048656888626d35843a1 (diff)
Edje entry: Fix anchor href parsing.
It should now correctly work with arguments surrounded with either quotes or spaces.
Diffstat (limited to 'src')
-rw-r--r--src/lib/edje/edje_entry.c46
1 files changed, 44 insertions, 2 deletions
diff --git a/src/lib/edje/edje_entry.c b/src/lib/edje/edje_entry.c
index 40592af05a..5754a578ab 100644
--- a/src/lib/edje/edje_entry.c
+++ b/src/lib/edje/edje_entry.c
@@ -1037,6 +1037,48 @@ _anchors_clear(Evas_Textblock_Cursor *c EINA_UNUSED, Evas_Object *o EINA_UNUSED,
1037 } 1037 }
1038} 1038}
1039 1039
1040/* FIXME: This is horrible. It's just a copy&paste (with some adjustments)
1041 * from textblock. I didn't want to introduce any non-API links between the
1042 * libs so I just copied it. Should have been handled differently. */
1043static char *
1044_anchor_format_parse(const char *item)
1045{
1046 const char *start, *end;
1047 char *tmp;
1048 size_t len;
1049
1050 start = strchr(item, '=');
1051 start++; /* Advance after the '=' */
1052 /* If we can find a quote as the first non-space char,
1053 * our new delimiter is a quote, not a space. */
1054 while (*start == ' ')
1055 start++;
1056
1057 if (*start == '\'')
1058 {
1059 start++;
1060 end = strchr(start, '\'');
1061 while ((end) && (end > start) && (end[-1] == '\\'))
1062 end = strchr(end + 1, '\'');
1063 }
1064 else
1065 {
1066 end = strchr(start, ' ');
1067 while ((end) && (end > start) && (end[-1] == '\\'))
1068 end = strchr(end + 1, ' ');
1069 }
1070
1071 /* Null terminate before the spaces */
1072 if (end) len = end - start;
1073 else len = strlen(start);
1074
1075 tmp = malloc(len);
1076 strncpy(tmp, start, len);
1077 tmp[len] = '\0';
1078
1079 return tmp;
1080}
1081
1040static void 1082static void
1041_anchors_get(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en) 1083_anchors_get(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en)
1042{ 1084{
@@ -1063,7 +1105,7 @@ _anchors_get(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en)
1063 p = strstr(s, "href="); 1105 p = strstr(s, "href=");
1064 if (p) 1106 if (p)
1065 { 1107 {
1066 an->name = strdup(p + 5); 1108 an->name = _anchor_format_parse(p);
1067 } 1109 }
1068 en->anchors = eina_list_append(en->anchors, an); 1110 en->anchors = eina_list_append(en->anchors, an);
1069 an->start = evas_object_textblock_cursor_new(o); 1111 an->start = evas_object_textblock_cursor_new(o);
@@ -1114,7 +1156,7 @@ _anchors_get(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en)
1114 p = strstr(s, "href="); 1156 p = strstr(s, "href=");
1115 if (p) 1157 if (p)
1116 { 1158 {
1117 an->name = strdup(p + 5); 1159 an->name = _anchor_format_parse(p);
1118 } 1160 }
1119 en->anchors = eina_list_append(en->anchors, an); 1161 en->anchors = eina_list_append(en->anchors, an);
1120 an->start = evas_object_textblock_cursor_new(o); 1162 an->start = evas_object_textblock_cursor_new(o);