summaryrefslogtreecommitdiff
blob: fdd98624a6ea0f7b91e9115c5432364d6e1f5ba3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
diff --git a/lib/compat/glib.c b/lib/compat/glib.c
index 8b6e52447..5b8ed8891 100644
--- a/lib/compat/glib.c
+++ b/lib/compat/glib.c
@@ -315,3 +315,18 @@ slng_g_hash_table_insert(GHashTable *hash_table, gpointer key, gpointer value)
   return exists;
 }
 #endif
+
+
+#if !GLIB_CHECK_VERSION(2, 64, 0)
+gunichar
+g_utf8_get_char_validated_fixed(const gchar *p, gssize max_len)
+{
+  // https://github.com/GNOME/glib/commit/1963821a57584b4674c20895e8a5adccd2d9effd
+
+#undef g_utf8_get_char_validated
+  if (*p == '\0' && max_len > 0)
+    return (gunichar)-2;
+
+  return g_utf8_get_char_validated(p, max_len);
+}
+#endif
diff --git a/lib/compat/glib.h b/lib/compat/glib.h
index a9782ed2d..0fbdbd12d 100644
--- a/lib/compat/glib.h
+++ b/lib/compat/glib.h
@@ -109,4 +109,9 @@ gchar *g_base64_encode_fixed(const guchar *data, gsize len);
 gboolean slng_g_hash_table_insert (GHashTable *hash_table, gpointer key, gpointer value);
 #endif
 
+#if !GLIB_CHECK_VERSION(2, 64, 0)
+#define g_utf8_get_char_validated g_utf8_get_char_validated_fixed
+gunichar g_utf8_get_char_validated_fixed (const gchar *p, gssize max_len);
+#endif
+
 #endif
diff --git a/modules/cef/tests/test-format-cef-extension.c b/modules/cef/tests/test-format-cef-extension.c
index d7f6ee3c1..f4233f96f 100644
--- a/modules/cef/tests/test-format-cef-extension.c
+++ b/modules/cef/tests/test-format-cef-extension.c
@@ -104,7 +104,7 @@ Test(format_cef, test_null_in_value)
 
   configuration->template_options.on_error = ON_ERROR_DROP_MESSAGE | ON_ERROR_SILENT;
   log_msg_set_value_by_name(msg, ".cef.k", "a\0b", 3);
-  assert_template_format_msg("$(format-cef-extension --subkeys .cef.)", "k=a\\u0000b", msg);
+  assert_template_format_msg("$(format-cef-extension --subkeys .cef.)", "k=a\\x00b", msg);
   log_msg_unref(msg);
 }
 
diff --git a/modules/json/tests/test_format_json.c b/modules/json/tests/test_format_json.c
index 92c61e9f1..1224ddb33 100644
--- a/modules/json/tests/test_format_json.c
+++ b/modules/json/tests/test_format_json.c
@@ -55,7 +55,7 @@ Test(format_json, test_format_json)
   assert_template_format("$(format-json MSG=$escaping)",
                          "{\"MSG\":\"binary stuff follows \\\"\\\\xad árvíztűrőtükörfúrógép\"}");
   assert_template_format("$(format-json MSG=$escaping2)", "{\"MSG\":\"\\\\xc3\"}");
-  assert_template_format("$(format-json MSG=$null)", "{\"MSG\":\"binary\\u0000stuff\"}");
+  assert_template_format("$(format-json MSG=$null)", "{\"MSG\":\"binary\\\\x00stuff\"}");
   assert_template_format_with_context("$(format-json MSG=$MSG)",
                                       "{\"MSG\":\"árvíztűrőtükörfúrógép\"}{\"MSG\":\"árvíztűrőtükörfúrógép\"}");
   assert_template_format("$(format-json --scope rfc3164)",