Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F58399941
lazyLoadImgPart2
LMora-WMF (LorenMora)
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Authored By
LMora-WMF
Feb 14 2025, 7:05 PM
2025-02-14 19:05:10 (UTC+0)
Size
2 KB
Referenced Files
None
Subscribers
None
lazyLoadImgPart2
View Options
diff --git a/includes/Transforms/LazyImageTransform.php b/includes/Transforms/LazyImageTransform.php
index 5a9342782..30c9018c1 100644
--- a/includes/Transforms/LazyImageTransform.php
+++ b/includes/Transforms/LazyImageTransform.php
@@ -195,7 +195,7 @@ class LazyImageTransform implements IMobileTransform {
);
foreach ( [ 'src', 'alt', 'width', 'height', 'srcset', 'class', 'usemap' ] as $attr ) {
if ( $img->hasAttribute( $attr ) ) {
- $prefix = $attr === 'src' ? 'data-mw-' : 'data-';
+ $prefix = ( $attr === 'src' || $attr === 'srcset' ) ? 'data-mw-' : 'data-';
$imgPlaceholder->setAttribute( $prefix . $attr, $img->getAttribute( $attr ) );
}
}
diff --git a/resources/dist/mobile.common.js b/resources/dist/mobile.common.js
index 4897aaf06..3f6031048 100644
Binary files a/resources/dist/mobile.common.js and b/resources/dist/mobile.common.js differ
diff --git a/resources/dist/mobile.common.js.map.json b/resources/dist/mobile.common.js.map.json
index 5a3ea399b..6e484affa 100644
Binary files a/resources/dist/mobile.common.js.map.json and b/resources/dist/mobile.common.js.map.json differ
diff --git a/src/mobile.startup/lazyImages/lazyImageLoader.js b/src/mobile.startup/lazyImages/lazyImageLoader.js
index 3f21ee594..ca721a69b 100644
--- a/src/mobile.startup/lazyImages/lazyImageLoader.js
+++ b/src/mobile.startup/lazyImages/lazyImageLoader.js
@@ -75,9 +75,11 @@ function loadImage( placeholder ) {
}, { once: true } );
// Trigger image download after binding the load handler
- // Todo: Remove placeholder.dataset.src once cache is reset
- image.src = placeholder.dataset.mwSrc || placeholder.dataset.src || '';
- image.srcset = placeholder.dataset.srcset || '';
+ const src = placeholder.dataset.mwSrc || '';
+ if ( src ) {
+ image.src = src;
+ image.srcset = placeholder.dataset.mwSrcset || '';
+ }
return {
promise: deferred,
diff --git a/tests/phpunit/unit/transforms/LazyImageTransformTest.php b/tests/phpunit/unit/transforms/LazyImageTransformTest.php
index b7d683681..7f1deff7a 100644
--- a/tests/phpunit/unit/transforms/LazyImageTransformTest.php
+++ b/tests/phpunit/unit/transforms/LazyImageTransformTest.php
@@ -199,7 +199,8 @@ class LazyImageTransformTest extends \MediaWikiUnitTestCase {
public static function provideTransform() {
$img = '<img src="kitty.jpg" width="500" height="400">';
$placeholder = '<span class="lazy-image-placeholder" style="width: 500px;height: 400px;" '
- . 'data-mw-src="kitty.jpg" data-width="500" data-height="400"> </span>';
+ . 'data-mw-src="kitty.jpg" data-width="500" data-height="400" '
+ . 'data-mw-srcset="foo-1.5x.jpg 1.5x, foo-2x.jpg 2x"> </span>';
$imgStyle = '<img src="bigPicture.jpg" style="vertical-align: top; '
. 'width: 84.412ex; height:70.343ex; background:none;">';
File Metadata
Details
Attached
Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
19261959
Default Alt Text
lazyLoadImgPart2 (2 KB)
Attached To
Mode
T366402: CVE-2025-32080: Cross-origin data leak in mobilefrontend via lazy load images
Attached
Detach File
Event Timeline
Log In to Comment