From 914d7c03efb7be19d7b3b81ce452a77fa959a19d Mon Sep 17 00:00:00 2001 From: Wonki Kim Date: Tue, 6 Dec 2016 11:24:28 +0900 Subject: [PATCH] edje_entry: Support multibyte on result of retrieve_surrounding_cb Summary: to make a result of retrieve_surrounding_cb secure, callback result string will be replaced by star('*') when entry is password mode. however, if plain_text was multibyte, too many stars are displayed than it's actual length. Reviewers: jihoon, id213sin, woohyun, herdsman Subscribers: herdsman, cedric, jpeg Differential Revision: https://phab.enlightenment.org/D4427 Change-Id: Id321bf7c7db987a3795c4f33d80554f36e6bb06b Signed-off-by: Wonki Kim --- src/lib/edje/edje_entry.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/src/lib/edje/edje_entry.c b/src/lib/edje/edje_entry.c index 672c79a..66c586a 100644 --- a/src/lib/edje/edje_entry.c +++ b/src/lib/edje/edje_entry.c @@ -4734,14 +4734,16 @@ _edje_entry_imf_cursor_info_set(Entry *en) #ifdef HAVE_ECORE_IMF static Eina_Bool -_edje_entry_imf_retrieve_surrounding_cb(void *data, Ecore_IMF_Context *ctx EINA_UNUSED, char **text, int *cursor_pos) +_edje_entry_imf_retrieve_surrounding_cb(void *data, Ecore_IMF_Context *ctx, char **text, int *cursor_pos) { Edje *ed = data; Edje_Real_Part *rp = ed->focused_part; Entry *en = NULL; const char *str; char *plain_text; - +// TIZEN_ONLY(20161206): Support multibyte on result of retrieve_surrounding_cb + int i = 0, len = 0; +// END if (!rp) return EINA_FALSE; if ((rp->type != EDJE_RP_TYPE_TEXT) || (!rp->typedata.text)) return EINA_FALSE; @@ -4760,13 +4762,6 @@ _edje_entry_imf_retrieve_surrounding_cb(void *data, Ecore_IMF_Context *ctx EINA_ if (plain_text) { - if(ecore_imf_context_input_hint_get(ctx) & ECORE_IMF_INPUT_HINT_SENSITIVE_DATA) - { - char *itr = NULL; - for (itr = plain_text; itr && *itr; itr++) - *itr = '*'; - } - *text = strdup(plain_text); free(plain_text); plain_text = NULL; @@ -4776,6 +4771,20 @@ _edje_entry_imf_retrieve_surrounding_cb(void *data, Ecore_IMF_Context *ctx EINA_ } else *text = strdup(""); + +// TIZEN_ONLY(20161206): Support multibyte on result of retrieve_surrounding_cb + if (ctx && (ecore_imf_context_input_hint_get(ctx) & ECORE_IMF_INPUT_HINT_SENSITIVE_DATA)) + { + len = eina_unicode_utf8_get_len(*text); + *text = realloc(*text, (1+len)*sizeof(char)); + if(*text) + { + for (i = 0; i < len; i++) + (*text)[i] = '*'; + (*text)[len] = '\0'; + } + } +// END } if (cursor_pos) -- 2.7.4