Skip to content

Commit ef12806

Browse files
committed
#282 Added support for different line breaks
1 parent faeef90 commit ef12806

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/Loader/StrictPoLoader.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ private function readNumber(): string
143143
*/
144144
private function readCommentString(): string
145145
{
146-
for ($data = ''; ($this->getChar() ?? "\n") !== "\n"; $data .= $this->nextChar());
146+
for ($data = ''; ($char = $this->getChar() ?? "\n") !== "\n" && $char !== "\r"; $data .= $this->nextChar());
147147
return $data;
148148
}
149149

@@ -177,13 +177,13 @@ private function readQuotedString(): string
177177
for (; ($char = $this->getChar() ?? '"') !== '"'; $data .= $char) {
178178
$this->nextChar();
179179
if ($char === '\\') {
180-
if (($alias = $aliases[$this->nextChar()] ?? null) === null) {
180+
// Ensures the next char is a valid escape character
181+
if (($char = $aliases[$this->nextChar()] ?? null) === null) {
181182
throw new Exception("Invalid quoted character at byte {$this->position}");
182183
}
183-
$char = $alias;
184184
continue;
185185
}
186-
if ($char === "\n") {
186+
if ($char === "\n" || $char === "\r") {
187187
throw new Exception("New line character must be encoded at byte {$this->position}");
188188
}
189189
}

0 commit comments

Comments
 (0)