jenkins-bot has submitted this change and it was merged.
Change subject: mediawiki.Title: Generalise filename-matching in newFromImg
......................................................................
mediawiki.Title: Generalise filename-matching in newFromImg
Both core and extensions can (and do) modify the thumbnail string
e.g. to add page numbers, languages, etc.
As bawolff notes in the commentary to bug 55963, the assumption
that the filename itself appears twice is likely to be violated
from time to time, but for the moment it suffices to fix the
apparent regression described in that bug report.
Also includes some additional test cases.
Bug: 55963
Change-Id: I9bb29a24f9bf50924699b913e31f44689906c525
---
M resources/mediawiki/mediawiki.Title.js
M tests/qunit/suites/resources/mediawiki/mediawiki.Title.test.js
2 files changed, 17 insertions(+), 4 deletions(-)
Approvals:
Krinkle: Looks good to me, approved
jenkins-bot: Verified
diff --git a/resources/mediawiki/mediawiki.Title.js
b/resources/mediawiki/mediawiki.Title.js
index b236019..4a64566 100644
--- a/resources/mediawiki/mediawiki.Title.js
+++ b/resources/mediawiki/mediawiki.Title.js
@@ -312,13 +312,12 @@
// thumb.php-generated thumbnails
thumbPhpRegex = /thumb\.php/,
-
regexes = [
// Thumbnails
-
/\/[a-f0-9]\/[a-f0-9]{2}\/([^\s\/]+)\/[0-9]+px-\1[^\s\/]*$/,
+
/\/[a-f0-9]\/[a-f0-9]{2}\/([^\s\/]+)\/[^\s\/]+-\1[^\s\/]*$/,
// Thumbnails in non-hashed upload directories
- /\/([^\s\/]+)\/[0-9]+px-\1[^\s\/]*$/,
+ /\/([^\s\/]+)\/[^\s\/]+-\1[^\s\/]*$/,
// Full size images
/\/[a-f0-9]\/[a-f0-9]{2}\/([^\s\/]+)$/,
diff --git a/tests/qunit/suites/resources/mediawiki/mediawiki.Title.test.js
b/tests/qunit/suites/resources/mediawiki/mediawiki.Title.test.js
index ba15fba..13c0efc 100644
--- a/tests/qunit/suites/resources/mediawiki/mediawiki.Title.test.js
+++ b/tests/qunit/suites/resources/mediawiki/mediawiki.Title.test.js
@@ -330,7 +330,7 @@
assert.equal( title.getUrl(), '/wiki/User_talk:John_Doe',
'Escaping in title and namespace for urls' );
} );
- QUnit.test( 'newFromImg', 28, function ( assert ) {
+ QUnit.test( 'newFromImg', 36, function ( assert ) {
var title, i, thisCase, prefix,
cases = [
{
@@ -338,6 +338,13 @@
typeOfUrl: 'Normal hashed directory
thumbnail',
nameText: 'Anticlockwise heliotrope\'s',
prefixedText: 'File:Anticlockwise
heliotrope\'s.jpg'
+ },
+
+ {
+ url:
'/wiki/images/thumb/8/80/Wikipedia-logo-v2.svg/langde-150px-Wikipedia-logo-v2.svg.png',
+ typeOfUrl: 'Normal hashed directory
thumbnail with complex thumbnail parameters',
+ nameText: 'Wikipedia-logo-v2',
+ prefixedText:
'File:Wikipedia-logo-v2.svg'
},
{
@@ -369,6 +376,13 @@
},
{
+ url:
'/wikipedia/commons/thumb/Wikipedia-logo-v2.svg/langde-150px-Wikipedia-logo-v2.svg.png',
+ typeOfUrl: 'Commons unhashed thumbnail
with complex thumbnail parameters',
+ nameText: 'Wikipedia-logo-v2',
+ prefixedText:
'File:Wikipedia-logo-v2.svg'
+ },
+
+ {
url:
'/wiki/images/Anticlockwise_heliotrope%27s.jpg',
typeOfUrl: 'Unhashed local file',
nameText: 'Anticlockwise heliotrope\'s',
--
To view, visit https://gerrit.wikimedia.org/r/90897
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I9bb29a24f9bf50924699b913e31f44689906c525
Gerrit-PatchSet: 6
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Jarry1250 <[email protected]>
Gerrit-Reviewer: Bartosz DziewoĆski <[email protected]>
Gerrit-Reviewer: Krinkle <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits