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>
This commit is contained in:
parent
329e54010b
commit
089d432040
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue