Skip to content

Commit

Permalink
php-gettext#282 Added support for different line breaks
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasraoni committed Jul 22, 2022
1 parent faeef90 commit ef12806
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Loader/StrictPoLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ private function readNumber(): string
*/
private function readCommentString(): string
{
for ($data = ''; ($this->getChar() ?? "\n") !== "\n"; $data .= $this->nextChar());
for ($data = ''; ($char = $this->getChar() ?? "\n") !== "\n" && $char !== "\r"; $data .= $this->nextChar());
return $data;
}

Expand Down Expand Up @@ -177,13 +177,13 @@ private function readQuotedString(): string
for (; ($char = $this->getChar() ?? '"') !== '"'; $data .= $char) {
$this->nextChar();
if ($char === '\\') {
if (($alias = $aliases[$this->nextChar()] ?? null) === null) {
// Ensures the next char is a valid escape character
if (($char = $aliases[$this->nextChar()] ?? null) === null) {
throw new Exception("Invalid quoted character at byte {$this->position}");
}
$char = $alias;
continue;
}
if ($char === "\n") {
if ($char === "\n" || $char === "\r") {
throw new Exception("New line character must be encoded at byte {$this->position}");
}
}
Expand Down

0 comments on commit ef12806

Please sign in to comment.