discomfitor pushed a commit to branch master.

http://git.enlightenment.org/apps/empc.git/commit/?id=5604b52a2d74263a308d09254b07ba705f24dc64

commit 5604b52a2d74263a308d09254b07ba705f24dc64
Author: Mike Blumenkrantz <[email protected]>
Date:   Sat May 28 13:04:10 2016 -0400

    update google image fetcher to new google json code
---
 src/modules/google_image.c | 71 ++++++++++++++++++++++++++++------------------
 1 file changed, 43 insertions(+), 28 deletions(-)

diff --git a/src/modules/google_image.c b/src/modules/google_image.c
index 64b7b2a..092215c 100644
--- a/src/modules/google_image.c
+++ b/src/modules/google_image.c
@@ -43,41 +43,56 @@ gend(GImage_Data *gi, Ecore_Thread *eth EINA_UNUSED)
 static void
 gparse(GImage_Data *gi, Ecore_Thread *eth)
 {
-   const char *s, *e, *pct, *p = eina_strbuf_string_get(gi->data);
+   const char *s, *e, *p = eina_strbuf_string_get(gi->data);
    unsigned int count = 0;
+#define MARKER_ONE "\"ou\":\""
 
    do {
-      const char *use = NULL;
-      s = strstr(p, "imgurl=");
+      char *use, *enc;
+
+      s = strstr(p, MARKER_ONE);
       if (!s) break;
-      s += sizeof("imgurl=") - 1;
-      if (!memcmp(s, "&amp;", sizeof("&amp;") - 1))
+      s += sizeof(MARKER_ONE) - 1;
+      e = strchr(s, '"');
+      if (!e) break;
+      enc = memchr(s, '\\', e - s);
+      if (enc)
         {
+           Eina_Strbuf *sbuf = eina_strbuf_new();
            p = s;
-           continue;
+
+           /* encoded ascii */
+           while (enc)
+             {
+                int c;
+                char buf[5] = {0};
+
+                eina_strbuf_append_length(sbuf, p, enc - p);
+                if ((!p[1]) || (!p[2]))
+                  {
+                     E_FREE_FUNC(sbuf, eina_strbuf_free);
+                     break;
+                  }
+                p = enc += 2;
+                strncpy(buf, enc, 4);
+                c = strtol(buf, NULL, 16);
+                if (c < 0)
+                  {
+                     E_FREE_FUNC(sbuf, eina_strbuf_free);
+                     break;
+                  }
+                p = enc += 4;
+                eina_strbuf_append_char(sbuf, c);
+                enc = memchr(enc, '\\', e - p);
+             }
+           eina_strbuf_append_length(sbuf, p, e - p);
+           use = eina_strbuf_string_steal(sbuf);
+           eina_strbuf_free(sbuf);
         }
-      e = strstr(s, "&amp;");
-      pct = s;
-      do
-        {
-           const char *dot;
-
-           pct = memchr(pct + 1, '%', e - pct - 1);
-           if (!pct) break;
-           for (dot = pct; (dot != s) && (pct - dot < 6); dot--)
-             if (dot[0] == '.')
-               {
-                  char buf[128] = {0};
-
-                  memcpy(buf, dot, pct - dot);
-                  if (evas_object_image_extension_can_load_get(buf))
-                    use = pct;
-                  break;
-               }
-        } while (!use);
-      if (!use)
-        use = e;
-      ecore_thread_feedback(eth, strndup(s, use - s));
+      else
+        use = (char*)eina_memdup((void*)s, e - s, 1);
+
+      ecore_thread_feedback(eth, use);
       count++;
       if (count > 10) break;
       p = e;

-- 


Reply via email to