1
0
mirror of https://github.com/erusev/parsedown.git synced 2023-08-10 21:13:06 +03:00

Ensure $startPosition is positive

This commit is contained in:
Aidan Woods
2019-02-10 22:35:27 +00:00
parent cef5b16ae0
commit 30613b2430
2 changed files with 1 additions and 9 deletions

View File

@@ -42,20 +42,12 @@ final class HardBreak implements Inline
$context = $Excerpt->context();
$offset = $Excerpt->offset();
if ($offset < 1) {
return null;
}
if (\substr($context, $offset -1, 1) === '\\') {
$contentLen = $offset -1;
return new self($offset - $contentLen, $contentLen);
}
if ($offset < 2) {
return null;
}
if (\substr($context, $offset -2, 2) === ' ') {
$trimTrailingWhitespace = \rtrim(\substr($context, 0, $offset));
$contentLen = \strlen($trimTrailingWhitespace);