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:
parent
cef5b16ae0
commit
30613b2430
@ -42,20 +42,12 @@ final class HardBreak implements Inline
|
|||||||
$context = $Excerpt->context();
|
$context = $Excerpt->context();
|
||||||
$offset = $Excerpt->offset();
|
$offset = $Excerpt->offset();
|
||||||
|
|
||||||
if ($offset < 1) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (\substr($context, $offset -1, 1) === '\\') {
|
if (\substr($context, $offset -1, 1) === '\\') {
|
||||||
$contentLen = $offset -1;
|
$contentLen = $offset -1;
|
||||||
|
|
||||||
return new self($offset - $contentLen, $contentLen);
|
return new self($offset - $contentLen, $contentLen);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($offset < 2) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (\substr($context, $offset -2, 2) === ' ') {
|
if (\substr($context, $offset -2, 2) === ' ') {
|
||||||
$trimTrailingWhitespace = \rtrim(\substr($context, 0, $offset));
|
$trimTrailingWhitespace = \rtrim(\substr($context, 0, $offset));
|
||||||
$contentLen = \strlen($trimTrailingWhitespace);
|
$contentLen = \strlen($trimTrailingWhitespace);
|
||||||
|
@ -209,7 +209,7 @@ final class Parsedown
|
|||||||
|
|
||||||
# makes sure that the inline belongs to "our" marker
|
# makes sure that the inline belongs to "our" marker
|
||||||
|
|
||||||
if ($startPosition > $Excerpt->offset()) {
|
if ($startPosition > $Excerpt->offset() || $startPosition < 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user