Skip to content

Commit edfa29b

Browse files
committed
feat(comment): support literal LF char inside string
1 parent cf79981 commit edfa29b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/Comment.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,15 @@ protected function reset()
6060
protected function doStrip(string $json): string
6161
{
6262
$return = '';
63+
$crlf = ["\n" => '\n', "\r" => '\r'];
6364

6465
while (isset($json[++$this->index])) {
6566
list($prev, $char, $next) = $this->getSegments($json);
6667

6768
$return = $this->checkTrail($char, $return);
6869

6970
if ($this->inStringOrCommentEnd($prev, $char, $char . $next)) {
70-
$return .= $char;
71+
$return .= $this->inStr && isset($crlf[$char]) ? $crlf[$char] : $char;
7172

7273
continue;
7374
}

0 commit comments

Comments
 (0)