aboutsummaryrefslogtreecommitdiffstats
path: root/wsutil/json_dumper.c
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2019-02-10 00:34:32 +0100
committerAnders Broman <a.broman58@gmail.com>2019-02-12 04:44:00 +0000
commit089d432040e99cce190e5473f0cc4c9b88cd5e1f (patch)
treefcf7ca7ac2a6a1de3bdcfe6e3176886f2ca74954 /wsutil/json_dumper.c
parent329e54010b10aed4083ceae0900cc1dd873e90c7 (diff)
json_dumper: escape forward slash in some strings
If the JSON output is written in a script tag for a HTML page, be sure to not to break it. Change-Id: I1b9ba6a39faf266e8a7bf9befa2899978beb130c Reviewed-on: https://code.wireshark.org/review/31953 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Dario Lombardo <lomato@gmail.com> Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'wsutil/json_dumper.c')
-rw-r--r--wsutil/json_dumper.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/wsutil/json_dumper.c b/wsutil/json_dumper.c
index 6b48811659..93b03749f7 100644
--- a/wsutil/json_dumper.c
+++ b/wsutil/json_dumper.c
@@ -60,6 +60,9 @@ json_puts_string(FILE *fp, const char *str, gboolean dot_to_underscore)
if ((guint)str[i] < 0x20) {
fputc('\\', fp);
fputs(json_cntrl[(guint)str[i]], fp);
+ } else if (i > 0 && str[i - 1] == '<' && str[i] == '/') {
+ // Convert </script> to <\/script> to avoid breaking web pages.
+ fputs("\\/", fp);
} else {
if (str[i] == '\\' || str[i] == '"') {
fputc('\\', fp);