Skip to content

Commit f10139a

Browse files
authored
fix infinite loop for ml-string on first line (#44)
1 parent 9d20e1a commit f10139a

File tree

5 files changed

+8
-2
lines changed

5 files changed

+8
-2
lines changed

src/HJSON/HJSONParser.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,9 +368,8 @@ private function peek($offs)
368368
{
369369
$index = $this->at + $offs;
370370

371-
// Mimic old behavior with mb_substr
372371
if ($index < 0) {
373-
$index = 0;
372+
return null;
374373
}
375374
if ($index >= $this->textLengthChars) {
376375
return "";

tests/assets/failStr9a_test.hjson

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[
2+
[
3+
=
4+
[[''''''

tests/assets/strings3_result.hjson

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
""

tests/assets/strings3_result.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
""

tests/assets/strings3_test.hjson

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
''''''

0 commit comments

Comments
 (0)