Skip to content

Commit 0b94c6e

Browse files
committed
json-writer: fix wrong escaping of "\\/" as "\/"
1 parent f9a0682 commit 0b94c6e

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

json-writer.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ void JsonWriter::flush() {
105105
str.push(reFilter);
106106

107107
// create a regex-based filter to replace \/ (produced by newer boost) by /
108-
const boost::regex reSlash("([^\\\\]*)\\\\/");
109-
boost::iostreams::basic_regex_filter<char> reFilterSlash(reSlash, "\\1/");
108+
const boost::regex reSlash("([^\\\\]*(?:\\\\\\\\)*)(?:\\\\(/))?");
109+
boost::iostreams::basic_regex_filter<char> reFilterSlash(reSlash, "\\1\\2");
110110
str.push(reFilterSlash);
111111

112112
str.push(d->str);

tests/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,8 @@ set(testdir "${csdiff_SOURCE_DIR}/tests")
2323
set(csjson "${csgrep} --mode=json")
2424
set(diffcmd "diff -up")
2525

26-
# new versions of Boost tend to escape '/' in JSON strings, no idea why
26+
# unify the JSON output generated by different version of Boost
2727
set(jsfilter "sed")
28-
set(jsfilter "${jsfilter} -e 's|\\\\\\\\\\\\\\\\/|/|g'")
2928
set(jsfilter "${jsfilter} -e ':a;N;$!ba;s|:\\\\\\\\n *\\\\\\\\[|: [|g'")
3029

3130
macro(add_test_wrap test_name cmd)

0 commit comments

Comments
 (0)