[gtkhtml] Bug 729944 - UTF-8 characters are not always encoded correctly



commit 013ae1df0b4baccf02107b2cf077ba6ca4622aa8
Author: Jonas Hahnfeld <hahnjo hahnjo de>
Date:   Thu May 29 16:54:55 2014 +0200

    Bug 729944 - UTF-8 characters are not always encoded correctly

 gtkhtml/htmlengine-save.c |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)
---
diff --git a/gtkhtml/htmlengine-save.c b/gtkhtml/htmlengine-save.c
index 44b01d4..813cb49 100644
--- a/gtkhtml/htmlengine-save.c
+++ b/gtkhtml/htmlengine-save.c
@@ -37,6 +37,13 @@
 
 #include "gtkhtmldebug.h"
 
+/* %# = 2 characters
+ * at most 10 characters from gunichar = guint32 (0 to 4294967296)
+ * ;  = 1 character
+ * \0 = 1 character
+ */
+#define HTML_ENTITIES_MAX_LENGTH       14
+
 
 /* This routine was originally written by Daniel Velliard, (C) 1998 World Wide
  * Web Consortium.  */
@@ -107,9 +114,9 @@ html_encode_entities (const gchar *input,
                        /* Default case, just copy. */
                        *out++ = uc;
                } else {
-                       gchar buf[10], *ptr;
+                       gchar buf[HTML_ENTITIES_MAX_LENGTH], *ptr;
 
-                       g_snprintf (buf, 9, "&#%d;", uc);
+                       g_snprintf (buf, HTML_ENTITIES_MAX_LENGTH, "&#%d;", uc);
 
                        ptr = buf;
                        while (*ptr != 0)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]