evas_textblock: markup text: improve handling invalide escape characters

Improve handling invalid escape characters.

(*) When '&' character founded in Markup text.
      Old Behavior   : Any text after '&' (if it is not escape), all text will be discarded
      New Behavior : Any text after '&' (if it is not escape), will be processes as normal plain text.

Example:
     Markup  Text :  Hello X & Y & Z 1 2 3
     Old     output :  Hello
     New   output :  Hello X & Y & Z 1 2 3

This is related to T8077

Reviewed-by: Cedric BAIL <cedric.bail@free.fr>
Differential Revision: https://phab.enlightenment.org/D9489
This commit is contained in:
Ali Alzyod 2019-08-03 09:19:20 +00:00 committed by Cedric BAIL
parent a821eb456a
commit e08ca17488
2 changed files with 42 additions and 0 deletions

View File

@ -8144,6 +8144,12 @@ _evas_object_textblock_text_markup_prepend(Eo *eo_obj,
_prepend_escaped_char(cur, esc_start, esc_end + 1);
esc_start = esc_end = NULL;
}
else if (*p == 0 && esc_start) /* escape start with no end, append it as text */
{
_prepend_text_run(cur, esc_start, p);
esc_start = esc_end = NULL;
s = NULL;
}
else if (*p == 0)
{
_prepend_text_run(cur, s, p);
@ -8154,6 +8160,12 @@ _evas_object_textblock_text_markup_prepend(Eo *eo_obj,
}
if (*p == '<')
{
if (esc_start) /* escape start with no end, append it as text */
{
_prepend_text_run(cur, esc_start, p);
esc_start = esc_end = NULL;
s = NULL;
}
if (!esc_start)
{
/* Append the text prior to this to the textblock and mark
@ -8174,6 +8186,12 @@ _evas_object_textblock_text_markup_prepend(Eo *eo_obj,
}
else if (*p == '&')
{
if (esc_start) /* escape start with no end, append it as text */
{
_prepend_text_run(cur, esc_start, p);
esc_start = esc_end = NULL;
s = NULL;
}
if (!tag_start)
{
/* Append the text prior to this to the textblock and mark

View File

@ -4654,6 +4654,29 @@ EFL_START_TEST(efl_canvas_text_markup)
}
EFL_END_TEST
EFL_START_TEST(efl_canvas_text_markup_invalid_escape)
{
START_EFL_CANVAS_TEXT_TEST();
char * text1 = "Hello";
char * text2 = "Hello&123";
char * text3 = "Hello&123&456";
Evas_Coord fw1, fw2, fw3;
efl_text_markup_set(txt,text1);
efl_canvas_text_size_native_get(txt, &fw1, NULL);
efl_text_markup_set(txt,text2);
efl_canvas_text_size_native_get(txt, &fw2, NULL);
fail_if(fw2 <= fw1);
efl_text_markup_set(txt,text3);
efl_canvas_text_size_native_get(txt, &fw3, NULL);
fail_if(fw3 <= fw2);
END_EFL_CANVAS_TEXT_TEST();
}
EFL_END_TEST
EFL_START_TEST(efl_text_font)
{
START_EFL_CANVAS_TEXT_TEST();
@ -4715,6 +4738,7 @@ void evas_test_textblock(TCase *tc)
tcase_add_test(tc, efl_text);
tcase_add_test(tc, efl_canvas_text_cursor);
tcase_add_test(tc, efl_canvas_text_markup);
tcase_add_test(tc, efl_canvas_text_markup_invalid_escape);
tcase_add_test(tc, efl_text_font);
}