Skip to content

Commit c5a44a9

Browse files
committed
Fix substr with negative length
1 parent 9db72a0 commit c5a44a9

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/Sabberworm/CSS/Parser.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -583,8 +583,14 @@ private function inputLeft() {
583583
}
584584

585585
private function substr($iStart, $iLength) {
586+
if ($iLength < 0) {
587+
$iLength = $this->iLength - $iStart + $iLength;
588+
}
589+
if ($iStart + $iLength > $this->iLength) {
590+
$iLength = $this->iLength - $iStart;
591+
}
586592
$out = '';
587-
while ($iLength > 0 && $iStart < $this->iLength) {
593+
while ($iLength > 0) {
588594
$out .= $this->aText[$iStart];
589595
$iStart++;
590596
$iLength--;

0 commit comments

Comments
 (0)