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

Ensure marker is properly contained in the Inline

This commit is contained in:
Aidan Woods 2019-02-10 22:50:34 +00:00
parent dbe37bcb0e
commit b90efc69ec
No known key found for this signature in database
GPG Key ID: 9A6A8EFAA512BBB9

View File

@ -201,15 +201,19 @@ final class Parsedown
continue; continue;
} }
$markerPosition = $Excerpt->offset();
$startPosition = $Inline->modifyStartPositionTo(); $startPosition = $Inline->modifyStartPositionTo();
if (! isset($startPosition)) { if (! isset($startPosition)) {
$startPosition = $Excerpt->offset(); $startPosition = $markerPosition;
} }
# makes sure that the inline belongs to "our" marker $endPosition = $startPosition + $Inline->width();
if ($startPosition > $Excerpt->offset() || $startPosition < 0) { if ($startPosition > $markerPosition
|| $endPosition < $markerPosition
|| $startPosition < 0
) {
continue; continue;
} }
@ -222,7 +226,7 @@ final class Parsedown
# remove the examined text # remove the examined text
/** @psalm-suppress LoopInvalidation */ /** @psalm-suppress LoopInvalidation */
$Excerpt = $Excerpt->choppingFromOffset($startPosition + $Inline->width()); $Excerpt = $Excerpt->choppingFromOffset($endPosition);
continue 2; continue 2;
} }