facebook-json:`Special-case "$" to return root for json-glib < 0.99.2

Mon, 21 Dec 2015 16:31:26 -0500

author
dequis <dx@dxzone.com.ar>
date
Mon, 21 Dec 2015 16:31:26 -0500
changeset 37430
56c7dbe97266
parent 37429
7f8a2f301a82
child 37431
df4d0ab7eaae

facebook-json:`Special-case "$" to return root for json-glib < 0.99.2

Older glib versions didn't consider "$" to be a valid expression, and
threw this error:

Root node followed by invalid character '

(That's supposed to be '%c' with a \0)

Since this is possibly the simplest expression to parse, a g_strcmp0()
can do the job.

Thanks to advcomp2019 for reporting this bug and finding a test case
where this issue is reproducible every time (receiving events of people
joining or leaving in a groupchat)

Also thanks to EionRobb who realized what the bug was three hours ago
(and I didn't listen because I thought the previous bug was the same)

libpurple/protocols/facebook/json.c file | annotate | diff | comparison | revisions
--- a/libpurple/protocols/facebook/json.c	Mon Dec 21 16:31:00 2015 -0500
+++ b/libpurple/protocols/facebook/json.c	Mon Dec 21 16:31:26 2015 -0500
@@ -290,6 +290,11 @@
 	JsonNode *node;
 	JsonNode *ret;
 
+	/* Special case for json-glib < 0.99.2 */
+	if (purple_strequal(expr, "$")) {
+		return json_node_copy(root);
+	}
+
 	node = json_path_query(expr, root, &err);
 
 	if (err != NULL) {

mercurial