@@ -63,11 +63,12 @@ protected function doStrip(string $json): string
63
63
$ crlf = ["\n" => '\n ' , "\r" => '\r ' ];
64
64
65
65
while (isset ($ json [++$ this ->index ])) {
66
+ $ oldprev = $ prev ?? '' ;
66
67
list ($ prev , $ char , $ next ) = $ this ->getSegments ($ json );
67
68
68
69
$ return = $ this ->checkTrail ($ char , $ return );
69
70
70
- if ($ this ->inStringOrCommentEnd ($ prev , $ char , $ char . $ next )) {
71
+ if ($ this ->inStringOrCommentEnd ($ prev , $ char , $ char . $ next, $ oldprev )) {
71
72
$ return .= $ this ->inStr && isset ($ crlf [$ char ]) ? $ crlf [$ char ] : $ char ;
72
73
73
74
continue ;
@@ -115,19 +116,19 @@ protected function checkTrail(string $char, string $json): string
115
116
return $ json ;
116
117
}
117
118
118
- protected function inStringOrCommentEnd (string $ prev , string $ char , string $ next ): bool
119
+ protected function inStringOrCommentEnd (string $ prev , string $ char , string $ next, string $ oldprev ): bool
119
120
{
120
- return $ this ->inString ($ char , $ prev , $ next ) || $ this ->inCommentEnd ($ next );
121
+ return $ this ->inString ($ char , $ prev , $ next, $ oldprev ) || $ this ->inCommentEnd ($ next );
121
122
}
122
123
123
- protected function inString (string $ char , string $ prev , string $ next ): bool
124
+ protected function inString (string $ char , string $ prev , string $ next, string $ oldprev ): bool
124
125
{
125
126
if (0 === $ this ->comment && $ char === '" ' && $ prev !== '\\' ) {
126
127
return $ this ->inStr = !$ this ->inStr ;
127
128
}
128
129
129
130
if ($ this ->inStr && \in_array ($ next , ['": ' , '", ' , '"] ' , '"} ' ], true )) {
130
- $ this ->inStr = false ;
131
+ $ this ->inStr = " $ oldprev $ prev " !== '\\\\' ;
131
132
}
132
133
133
134
return $ this ->inStr ;
0 commit comments