summaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
authorGergely Nagy <algernon@balabit.hu>2012-04-13 13:14:22 +0200
committerGergely Nagy <algernon@balabit.hu>2012-04-13 13:14:22 +0200
commitfb7693f412485cebc8d4a0cc2b2ace424d60d65d (patch)
treee39c60fa23f51157725a1d902980c344b4770a67 /t
parentd0d14fda7c98bab9f92e14f9578676bc70962d25 (diff)
downloadlibumberlog-fb7693f412485cebc8d4a0cc2b2ace424d60d65d.tar.gz
libumberlog-fb7693f412485cebc8d4a0cc2b2ace424d60d65d.tar.xz
libumberlog-fb7693f412485cebc8d4a0cc2b2ace424d60d65d.zip
Implement string escaping.
With this patch, both JSON keys and values will be properly escaped. Signed-off-by: Gergely Nagy <algernon@balabit.hu>
Diffstat (limited to 't')
-rw-r--r--t/test_umberlog.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/t/test_umberlog.c b/t/test_umberlog.c
index f20d28b..26fbadb 100644
--- a/t/test_umberlog.c
+++ b/t/test_umberlog.c
@@ -190,6 +190,35 @@ test_no_timestamp (void)
closelog ();
}
+static void
+test_json_escape (void)
+{
+ char *msg;
+ struct json_object *jo;
+
+ openlog ("umberlog/test_json_escape", LOG_UL_NODISCOVER, LOG_LOCAL0);
+
+ msg = ul_format (LOG_DEBUG, "%s", __FUNCTION__,
+ "quotes", "Hi, \"quoted value\" speaking!",
+ "\"really\"", "yeah",
+ "control", "foo\nbar",
+ "utf8", "Árvíztűrő tükörfúrógép",
+ "junk", "\013foo",
+ NULL);
+ jo = parse_msg (msg);
+ free (msg);
+
+ verify_value (jo, "quotes", "Hi, \"quoted value\" speaking!");
+ verify_value (jo, "\"really\"", "yeah");
+ verify_value (jo, "control", "foo\nbar");
+ verify_value (jo, "utf8", "Árvíztűrő tükörfúrógép");
+ verify_value (jo, "junk", "\013foo");
+
+ json_object_put (jo);
+
+ closelog ();
+}
+
int
main (void)
{
@@ -198,6 +227,7 @@ main (void)
test_additional_fields ();
test_discover_priority ();
test_no_timestamp ();
+ test_json_escape ();
return 0;
}