aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2022-04-26 08:58:08 +0200
committerGravatar GitHub <noreply@github.com> 2022-04-26 08:58:08 +0200
commit0b86e347ef514439bf53b48620755ddd75a1b8a0 (patch)
tree6284417a8a55001d7a7b1fd37aaf60f90030442e /lib
parent046598e743ac77dc4457edd60e421fd0d1963949 (diff)
Fix lazyimg single quotes (#4330)
Little bug for cases with single quote in URL such as ```html <img src="123?format='jpg'" /> ``` Could probably be replaced by `loading="lazy"` in the future, and with a better DOM-aware method, for instance during SimplePie `add_attributes()`
Diffstat (limited to 'lib')
-rw-r--r--lib/lib_rss.php11
1 files changed, 8 insertions, 3 deletions
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
);
}