edje_entry: Support multibyte on result of retrieve_surrounding_cb
authorWonki Kim <wonki_.kim@samsung.com>
Tue, 6 Dec 2016 02:24:28 +0000 (11:24 +0900)
committerWonki Kim <wonki_.kim@samsung.com>
Mon, 2 Jan 2017 07:23:58 +0000 (16:23 +0900)
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 <wonki_.kim@samsung.com>
src/lib/edje/edje_entry.c

index 672c79a..66c586a 100644 (file)
@@ -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)