summaryrefslogtreecommitdiffstats
path: root/common/common.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-01-08 09:13:33 +0100
committerwm4 <wm4@nowhere>2016-01-08 09:22:25 +0100
commit6a73fcc9ed8578b410f0555b9346b3034058a6c7 (patch)
treefd8729b97fe410b0aae8b493611d113eccd58735 /common/common.c
parent2dd8982f738f287a21cecbc0746af7569ff04dd5 (diff)
downloadmpv-6a73fcc9ed8578b410f0555b9346b3034058a6c7.tar.bz2
mpv-6a73fcc9ed8578b410f0555b9346b3034058a6c7.tar.xz
common: allow "\/" as escape sequence
mp_parse_escape() is used by the JSON parser in json.c, and JSON allows escaping "/" (solidus). Although it makes no sense, apparently Javascript traditionally allowed that as escape sequence for working around issues with embedding Javascript in HTML. (Or something like this must have been the history of this issue.) Since it's valid in Javascript, it had to be valid in JSON as well, and JSON explicitly specifies it as valid escape. Fixes #2694.
Diffstat (limited to 'common/common.c')
-rw-r--r--common/common.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/common/common.c b/common/common.c
index d3dcb6171f..c943235c2a 100644
--- a/common/common.c
+++ b/common/common.c
@@ -148,7 +148,7 @@ void mp_append_utf8_bstr(void *talloc_ctx, struct bstr *buf, uint32_t codepoint)
bstr_xappend(talloc_ctx, buf, (bstr){data, output - data});
}
-// Parse a C-style escape beginning at code, and append the result to *str
+// Parse a C/JSON-style escape beginning at code, and append the result to *str
// using talloc. The input string (*code) must point to the first character
// after the initial '\', and after parsing *code is set to the first character
// after the current escape.
@@ -161,6 +161,7 @@ static bool mp_parse_escape(void *talloc_ctx, bstr *dst, bstr *code)
switch (code->start[0]) {
case '"': replace = '"'; break;
case '\\': replace = '\\'; break;
+ case '/': replace = '/'; break;
case 'b': replace = '\b'; break;
case 'f': replace = '\f'; break;
case 'n': replace = '\n'; break;