From 0b86e347ef514439bf53b48620755ddd75a1b8a0 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Tue, 26 Apr 2022 08:58:08 +0200 Subject: Fix lazyimg single quotes (#4330) Little bug for cases with single quote in URL such as ```html ``` Could probably be replaced by `loading="lazy"` in the future, and with a better DOM-aware method, for instance during SimplePie `add_attributes()` --- lib/lib_rss.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'lib/lib_rss.php') diff --git a/lib/lib_rss.php b/lib/lib_rss.php index 677e4a413..ad7d9f523 100644 --- a/lib/lib_rss.php +++ b/lib/lib_rss.php @@ -458,11 +458,16 @@ function validateEmailAddress($email) { * Add support of image lazy loading * Move content from src attribute to data-original * @param string $content is the text we want to parse + * @return string */ function lazyimg($content) { - return preg_replace( - '/<((?:img|iframe)[^>]+?)src=[\'"]([^"\']+)[\'"]([^>]*)>/i', - '<$1src="' . Minz_Url::display('/themes/icons/grey.gif') . '" data-original="$2"$3>', + return preg_replace([ + '/<((?:img|iframe)[^>]+?)src="([^"]+)"([^>]*)>/i', + "/<((?:img|iframe)[^>]+?)src='([^']+)'([^>]*)>/i", + ], [ + '<$1src="' . Minz_Url::display('/themes/icons/grey.gif') . '" data-original="$2"$3>', + "<$1src='" . Minz_Url::display('/themes/icons/grey.gif') . "' data-original='$2'$3>", + ], $content ); } -- cgit v1.2.3