From b90efc69ec43b078c93e857c3744efcb201490fd Mon Sep 17 00:00:00 2001 From: Aidan Woods Date: Sun, 10 Feb 2019 22:50:34 +0000 Subject: [PATCH] Ensure marker is properly contained in the Inline --- src/Parsedown.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Parsedown.php b/src/Parsedown.php index d74b6e1..eaa20b5 100644 --- a/src/Parsedown.php +++ b/src/Parsedown.php @@ -201,15 +201,19 @@ final class Parsedown continue; } + $markerPosition = $Excerpt->offset(); $startPosition = $Inline->modifyStartPositionTo(); 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; } @@ -222,7 +226,7 @@ final class Parsedown # remove the examined text /** @psalm-suppress LoopInvalidation */ - $Excerpt = $Excerpt->choppingFromOffset($startPosition + $Inline->width()); + $Excerpt = $Excerpt->choppingFromOffset($endPosition); continue 2; }