aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--NEWS1
-rw-r--r--src/lib/evas/canvas/evas_object_textblock.c84
-rw-r--r--src/tests/evas/evas_test_textblock.c4
4 files changed, 49 insertions, 45 deletions
diff --git a/ChangeLog b/ChangeLog
index 85dcb1808e..1a50d14e6e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2013-09-03 Tom Hacohen
+
+ * Evas textblock: fixed an issue with markup_get and markup_to_utf8
+ behaving differently (markup_get was misbehaving).
+
2013-09-02 Shinwoo Kim
* Ecore_Input_Evas: Check the state of last mouse event more properly.
diff --git a/NEWS b/NEWS
index df5af760a6..1da60c23f4 100644
--- a/NEWS
+++ b/NEWS
@@ -333,6 +333,7 @@ Fixes:
- Fix a long-standing off-by-1 in the C "simd" multiplier.
- Skip the map rendering if all points are transparent.
- Evas bidi: Fixed a bug causing BiDi not to work in some cases.
+ - Evas textblock: fixed an issue with markup_get and markup_to_utf8 behaving differently (markup_get was misbehaving).
* Ecore:
- Don't leak fd on exec.
- Fix fd handler increase issue when ecore_pipe_add/del is called repeatedly.
diff --git a/src/lib/evas/canvas/evas_object_textblock.c b/src/lib/evas/canvas/evas_object_textblock.c
index c9a5b82c40..7ef33df247 100644
--- a/src/lib/evas/canvas/evas_object_textblock.c
+++ b/src/lib/evas/canvas/evas_object_textblock.c
@@ -6129,6 +6129,43 @@ _markup_get_format_append(Eina_Strbuf *txt, Evas_Object_Textblock_Node_Format *f
/**
* @internal
+ * An helper function to _markup_get_text_append and others, used for getting
+ * back only the "dangerous" escapes.
+ */
+static void
+_markup_get_text_utf8_append(Eina_Strbuf *sbuf, const char *text)
+{
+ int ch, pos = 0, pos2 = 0;
+
+ for (;;)
+ {
+ pos = pos2;
+ pos2 = evas_string_char_next_get(text, pos2, &ch);
+ if ((ch <= 0) || (pos2 <= 0)) break;
+
+ if (ch == _NEWLINE)
+ eina_strbuf_append(sbuf, "<br/>");
+ else if (ch == _TAB)
+ eina_strbuf_append(sbuf, "<tab/>");
+ else if (ch == '<')
+ eina_strbuf_append(sbuf, "&lt;");
+ else if (ch == '>')
+ eina_strbuf_append(sbuf, "&gt;");
+ else if (ch == '&')
+ eina_strbuf_append(sbuf, "&amp;");
+ else if (ch == _PARAGRAPH_SEPARATOR)
+ eina_strbuf_append(sbuf, "<ps/>");
+ else if (ch == _REPLACEMENT_CHAR)
+ eina_strbuf_append(sbuf, "&#xfffc;");
+ else if (ch != '\r')
+ {
+ eina_strbuf_append_length(sbuf, text + pos, pos2 - pos);
+ }
+ }
+}
+
+/**
+ * @internal
* An helper function to markup get. Appends the text in text.
*
* @param txt the strbuf to append to.
@@ -6137,25 +6174,10 @@ _markup_get_format_append(Eina_Strbuf *txt, Evas_Object_Textblock_Node_Format *f
static void
_markup_get_text_append(Eina_Strbuf *txt, const Eina_Unicode *text)
{
- char *p = eina_unicode_unicode_to_utf8(text, NULL);
- char *base = p;
- while (*p)
- {
- const char *escape;
- int adv;
+ char *base = eina_unicode_unicode_to_utf8(text, NULL);
+
+ _markup_get_text_utf8_append(txt, base);
- escape = _escaped_char_match(p, &adv);
- if (escape)
- {
- p += adv;
- eina_strbuf_append(txt, escape);
- }
- else
- {
- eina_strbuf_append_char(txt, *p);
- p++;
- }
- }
free(base);
}
EAPI const char *
@@ -6377,7 +6399,6 @@ evas_textblock_text_utf8_to_markup(const Evas_Object *eo_obj, const char *text)
{
Eina_Strbuf *sbuf;
char *str = NULL;
- int ch, pos = 0, pos2 = 0;
(void) eo_obj;
@@ -6385,31 +6406,8 @@ evas_textblock_text_utf8_to_markup(const Evas_Object *eo_obj, const char *text)
sbuf = eina_strbuf_new();
- for (;;)
- {
- pos = pos2;
- pos2 = evas_string_char_next_get(text, pos2, &ch);
- if ((ch <= 0) || (pos2 <= 0)) break;
+ _markup_get_text_utf8_append(sbuf, text);
- if (ch == _NEWLINE)
- eina_strbuf_append(sbuf, "<br/>");
- else if (ch == _TAB)
- eina_strbuf_append(sbuf, "<tab/>");
- else if (ch == '<')
- eina_strbuf_append(sbuf, "&lt;");
- else if (ch == '>')
- eina_strbuf_append(sbuf, "&gt;");
- else if (ch == '&')
- eina_strbuf_append(sbuf, "&amp;");
- else if (ch == _PARAGRAPH_SEPARATOR)
- eina_strbuf_append(sbuf, "<ps/>");
- else if (ch == _REPLACEMENT_CHAR)
- eina_strbuf_append(sbuf, "&#xfffc;");
- else if (ch != '\r')
- {
- eina_strbuf_append_length(sbuf, text + pos, pos2 - pos);
- }
- }
str = eina_strbuf_string_steal(sbuf);
eina_strbuf_free(sbuf);
return str;
diff --git a/src/tests/evas/evas_test_textblock.c b/src/tests/evas/evas_test_textblock.c
index 9f42021dc1..54865bb56e 100644
--- a/src/tests/evas/evas_test_textblock.c
+++ b/src/tests/evas/evas_test_textblock.c
@@ -2593,11 +2593,11 @@ START_TEST(evas_textblock_escaping)
const char *buf = "This &middot; is";
evas_object_textblock_text_markup_set(tb, buf);
- fail_if(strcmp(evas_object_textblock_text_markup_get(tb), buf));
+ fail_if(strcmp(evas_object_textblock_text_markup_get(tb), "This \xc2\xb7 is"));
buf = "This &nbsp; is";
evas_object_textblock_text_markup_set(tb, buf);
- fail_if(strcmp(evas_object_textblock_text_markup_get(tb), buf));
+ fail_if(strcmp(evas_object_textblock_text_markup_get(tb), "This \xc2\xa0 is"));
END_TB_TEST();
}