CommentFormatter: Fix regexp in topic subscription postprocessing

The regexps needs to be non-greedy, otherwise it could swallow up a
large chunk of the page (up to the next comment).

I noticed this when adding tests for this code, in the 'unclosed-font'
test case (Ief9648b8805fadcc170c54b627eb669cc8b907b6).

Change-Id: I5f67a9599b0cb07bdd53abeebac9ada221181b66
This commit is contained in:
Bartosz Dziewoński 2021-04-19 22:33:45 +02:00 committed by Esanders
parent 228b81fab9
commit 0b82162149

View file

@ -214,7 +214,7 @@ class CommentFormatter {
) : string {
$doc = new DOMDocument();
$text = preg_replace_callback(
'/<!--__DTSUBSCRIBE__(.*)-->/',
'/<!--__DTSUBSCRIBE__(.*?)-->/',
function ( $matches ) use ( $doc, $subscriptionStore, $user ) {
$itemName = $matches[1];
$items = $subscriptionStore->getSubscriptionItemsForUser(