@@ -63,11 +63,12 @@ protected function doStrip(string $json): string
6363 $ crlf = ["\n" => '\n ' , "\r" => '\r ' ];
6464
6565 while (isset ($ json [++$ this ->index ])) {
66+ $ oldprev = $ prev ?? '' ;
6667 list ($ prev , $ char , $ next ) = $ this ->getSegments ($ json );
6768
6869 $ return = $ this ->checkTrail ($ char , $ return );
6970
70- if ($ this ->inStringOrCommentEnd ($ prev , $ char , $ char . $ next )) {
71+ if ($ this ->inStringOrCommentEnd ($ prev , $ char , $ char . $ next, $ oldprev )) {
7172 $ return .= $ this ->inStr && isset ($ crlf [$ char ]) ? $ crlf [$ char ] : $ char ;
7273
7374 continue ;
@@ -115,19 +116,19 @@ protected function checkTrail(string $char, string $json): string
115116 return $ json ;
116117 }
117118
118- protected function inStringOrCommentEnd (string $ prev , string $ char , string $ next ): bool
119+ protected function inStringOrCommentEnd (string $ prev , string $ char , string $ next, string $ oldprev ): bool
119120 {
120- return $ this ->inString ($ char , $ prev , $ next ) || $ this ->inCommentEnd ($ next );
121+ return $ this ->inString ($ char , $ prev , $ next, $ oldprev ) || $ this ->inCommentEnd ($ next );
121122 }
122123
123- protected function inString (string $ char , string $ prev , string $ next ): bool
124+ protected function inString (string $ char , string $ prev , string $ next, string $ oldprev ): bool
124125 {
125126 if (0 === $ this ->comment && $ char === '" ' && $ prev !== '\\' ) {
126127 return $ this ->inStr = !$ this ->inStr ;
127128 }
128129
129130 if ($ this ->inStr && \in_array ($ next , ['": ' , '", ' , '"] ' , '"} ' ], true )) {
130- $ this ->inStr = false ;
131+ $ this ->inStr = " $ oldprev $ prev " !== '\\\\' ;
131132 }
132133
133134 return $ this ->inStr ;
0 commit comments