jenkins-bot has submitted this change and it was merged.

Change subject: Support manual thumbnail option (thumb=...) on images.
......................................................................


Support manual thumbnail option (thumb=...) on images.

Use a data-mw attribute (data.mw.thumb=Thumb.png) to record the name
of the manual thumb, since backing out the thumb title from a scaled
img src is problematic.

Change-Id: I91d170aa4f6d1fd844d24ccb85b886eb079e3e2a
---
M lib/ext.core.LinkHandler.js
M lib/mediawiki.Title.js
M lib/wts.LinkHandler.js
M tests/parserTests-blacklist.js
M tests/parserTests.txt
5 files changed, 67 insertions(+), 61 deletions(-)

Approvals:
  Subramanya Sastry: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/lib/ext.core.LinkHandler.js b/lib/ext.core.LinkHandler.js
index 364c52c..e5213e2 100644
--- a/lib/ext.core.LinkHandler.js
+++ b/lib/ext.core.LinkHandler.js
@@ -501,6 +501,16 @@
 }
 
 /**
+ * Get the format for an image.
+ */
+function getFormat( opts ) {
+       if ( opts.manualthumb ) {
+               return "thumbnail";
+       }
+       return opts.format && opts.format.v;
+}
+
+/**
  * Get the style and class lists for an image's wrapper element
  *
  * @private
@@ -514,10 +524,9 @@
  * @returns {Array} return.styles The list of styles for the wrapper
  */
 function getWrapperInfo( opts ) {
-       var format = opts.format && opts.format.v,
+       var format = getFormat( opts ),
                isInline = ! (format === 'thumbnail'
-                                               || format === 'framed'
-                                               || opts.manualthumb),
+                                               || format === 'framed'),
                wrapperStyles = [],
                wrapperClasses = [],
                halign = ( opts.format && opts.format.v === 'framed' ) ? 
'right' : null,
@@ -804,7 +813,7 @@
 
 // Handle a response to an imageinfo API request.
 // Set up the actual image structure, attributes etc
-WikiLinkHandler.prototype.handleImageInfo = function( cb, token, opts, 
optSources, err, data ) {
+WikiLinkHandler.prototype.handleImageInfo = function( cb, token, title, opts, 
optSources, err, data ) {
 
        if (err || !data) {
                // FIXME gwicke: Handle this error!!
@@ -813,8 +822,7 @@
                return;
        }
 
-       var     title = opts.title.v,
-               image, info,
+       var     image, info,
                rdfaType = 'mw:Image',
                hasImageLink = ( opts.link === undefined || opts.link && 
opts.link.v !== '' ),
                iContainerName = hasImageLink ? 'a' : 'span',
@@ -875,7 +883,7 @@
                img.addNormalizedAttribute( 'alt', opts.alt.v, opts.alt.src );
        }
 
-       img.addNormalizedAttribute( 'resource', title.makeLink(), 
opts.title.src );
+       img.addNormalizedAttribute( 'resource', opts.title.v.makeLink(), 
opts.title.src );
        img.addAttribute( 'src', getPath(info) );
 
        if ( opts.lang ) {
@@ -894,11 +902,11 @@
                        }
                        // No href if link= was specified
                } else {
-                       innerContain.addNormalizedAttribute( 'href', 
title.makeLink() );
+                       innerContain.addNormalizedAttribute( 'href', 
opts.title.v.makeLink() );
                }
        }
 
-       var format = opts.format && opts.format.v;
+       var format = getFormat( opts );
        if ( format === 'thumbnail' || format === 'framed' ) {
                if (opts.caption) {
                        opts.caption.v = Util.getDOMFragmentToken(
@@ -981,9 +989,13 @@
                                                new EndTagTk( 'figcaption' )
                                        ] );
                                } else {
-                                       obj = str ? JSON.parse(str) : {};
+                                       if (!obj) { obj = str ? JSON.parse(str) 
: {}; }
                                        obj.caption = opts.caption.src;
                                }
+                       }
+                       if (opts.manualthumb !== undefined) {
+                               if (!obj) { obj = str ? JSON.parse(str) : {}; }
+                               obj.thumb = opts.manualthumb.v;
                        }
 
                        if (obj) {
@@ -1247,9 +1259,19 @@
                optSources = null;
        }
 
+       // reset title if this is a manual thumbnail
+       if ( opts.manualthumb ) {
+               title = Title.fromPrefixedText( env, opts.manualthumb.v );
+               if (title.nskey === '') {
+                       // inherit namespace from main image
+                       title.ns = opts.title.v.ns;
+                       title.nskey = opts.title.v.nskey;
+               }
+       }
+
        var queueKey = title.key + JSON.stringify( opts.size.v );
        if (queueKey in env.pageCache) {
-               this.handleImageInfo( cb, token, opts, optSources, null, 
env.pageCache[ queueKey ] );
+               this.handleImageInfo( cb, token, title, opts, optSources, null, 
env.pageCache[ queueKey ] );
        } else {
                cb({ async: true });
 
@@ -1257,20 +1279,8 @@
                        env.requestQueue[queueKey] = new ImageInfoRequest( env, 
title.key, opts.size.v );
                }
 
-               env.requestQueue[queueKey].once( 'src', 
this.handleImageInfo.bind( this, cb, token, opts, optSources ) );
+               env.requestQueue[queueKey].once( 'src', 
this.handleImageInfo.bind( this, cb, token, title, opts, optSources ) );
        }
-};
-
-// Create an url for the scaled image src.
-// FIXME: This is just a dirty hack which will only ever work with the WMF
-// cluster configuration which creates an on-demand thumbnail when accessing a
-// width-prefixed image URL.
-WikiLinkHandler.prototype.getThumbPath = function ( key, width ) {
-       var env = this.manager.env,
-               // Make a relative link.
-               link = Title.fromPrefixedText( env, 'Special:FilePath' 
).makeLink();
-       // Simply let Special:FilePath redirect to the real thumb location
-       return link + '/' + key + '?width=' + width;
 };
 
 function ExternalLinkHandler( manager, options ) {
diff --git a/lib/mediawiki.Title.js b/lib/mediawiki.Title.js
index 01a13b9..64491d4 100644
--- a/lib/mediawiki.Title.js
+++ b/lib/mediawiki.Title.js
@@ -37,7 +37,7 @@
  * @static
  *
  * Take text, e.g. from a wikilink, and make a Title object from it.
- * Somewhat superseded by TemplateHandler.getWikiLinkTargetInfo.
+ * Somewhat superseded by WikiLinkHandler.getWikiLinkTargetInfo.
  *
  * @param {MWParserEnvironment} env
  * @param {string} text The prefixed text.
diff --git a/lib/wts.LinkHandler.js b/lib/wts.LinkHandler.js
index fee55dc..505704d 100644
--- a/lib/wts.LinkHandler.js
+++ b/lib/wts.LinkHandler.js
@@ -545,6 +545,7 @@
        var resource = this.serializedImageAttrVal( outerElt, imgElt, 
'resource' );
        if (resource.value === null) {
                // from non-parsoid HTML: try to reconstruct resource from src?
+               // (this won't work for manual-thumb images)
                var src = imgElt.getAttribute( 'src' );
                if (!src) {
                        this.env.log("error", "In WSP.handleImage, img does not 
have resource or src:", node.outerHTML);
@@ -683,6 +684,16 @@
        type = type ? type[1] : null;
        var framed = false;
 
+       var manualthumb = DU.getDataMw(outerElt).thumb;
+       if (manualthumb !== undefined) {
+               type = null;
+               nopts.push( {
+                       ck: 'manualthumb',
+                       ak: this.getAttributeValue(outerElt, 'manualthumb', 
mwAliases.img_manualthumb),
+                       v: manualthumb
+               } );
+       }
+
        switch ( type ) {
                case 'mw:Image/Thumb':
                        nopts.push( {
@@ -708,8 +719,6 @@
        }
 
        // XXX handle page
-       // XXX handle manualthumb
-
 
        // Handle width and height
 
diff --git a/tests/parserTests-blacklist.js b/tests/parserTests-blacklist.js
index 1b39ed6..6bde8d9 100644
--- a/tests/parserTests-blacklist.js
+++ b/tests/parserTests-blacklist.js
@@ -219,11 +219,6 @@
 add("wt2html", "Image with link parameter, wgNoFollowLinks set to false", "<p 
data-parsoid='{\"dsr\":[0,45,0,0]}'><span class=\"mw-default-size\" 
typeof=\"mw:Image\" 
data-parsoid='{\"optList\":[{\"ck\":\"link\",\"ak\":\"link=http://example.com/\"}],\"dsr\":[0,45,null,null]}'><a
 href=\"http://example.com/\"; data-parsoid=\"{}\"><img 
resource=\"./File:Foobar.jpg\" src=\"//example.com/images/3/3a/Foobar.jpg\" 
height=\"220\" width=\"1941\" 
data-parsoid='{\"a\":{\"resource\":\"./File:Foobar.jpg\",\"height\":\"220\",\"width\":\"1941\"},\"sa\":{\"resource\":\"Image:foobar.jpg\"}}'/></a></span></p>");
 add("wt2html", "Image with link parameter, wgNoFollowDomainExceptions", "<p 
data-parsoid='{\"dsr\":[0,45,0,0]}'><span class=\"mw-default-size\" 
typeof=\"mw:Image\" 
data-parsoid='{\"optList\":[{\"ck\":\"link\",\"ak\":\"link=http://example.com/\"}],\"dsr\":[0,45,null,null]}'><a
 href=\"http://example.com/\"; data-parsoid=\"{}\"><img 
resource=\"./File:Foobar.jpg\" src=\"//example.com/images/3/3a/Foobar.jpg\" 
height=\"220\" width=\"1941\" 
data-parsoid='{\"a\":{\"resource\":\"./File:Foobar.jpg\",\"height\":\"220\",\"width\":\"1941\"},\"sa\":{\"resource\":\"Image:foobar.jpg\"}}'/></a></span></p>");
 add("wt2html", "Image with link parameter, wgExternalLinkTarget, unnamed 
parameter", "<p data-parsoid='{\"dsr\":[0,51,0,0]}'><span 
class=\"mw-default-size\" typeof=\"mw:Image\" data-mw='{\"caption\":\"Title\"}' 
data-parsoid='{\"optList\":[{\"ck\":\"link\",\"ak\":\"link=http://example.com/\"},{\"ck\":\"caption\",\"ak\":\"Title\"}],\"dsr\":[0,51,null,null]}'><a
 href=\"http://example.com/\"; data-parsoid=\"{}\"><img 
resource=\"./File:Foobar.jpg\" src=\"//example.com/images/3/3a/Foobar.jpg\" 
height=\"220\" width=\"1941\" 
data-parsoid='{\"a\":{\"resource\":\"./File:Foobar.jpg\",\"height\":\"220\",\"width\":\"1941\"},\"sa\":{\"resource\":\"Image:foobar.jpg\"}}'/></a></span></p>");
-add("wt2html", "Manually-specified thumbnail image", "<figure 
class=\"mw-default-size\" typeof=\"mw:Image\" 
data-parsoid='{\"optList\":[{\"ck\":\"manualthumb\",\"ak\":\"thumb=Thumb.png\"},{\"ck\":\"caption\",\"ak\":\"Title\"}],\"dsr\":[0,42,2,2]}'><a
 href=\"./File:Foobar.jpg\" 
data-parsoid='{\"a\":{\"href\":\"./File:Foobar.jpg\"},\"dsr\":[2,null,null,null]}'><img
 resource=\"./File:Foobar.jpg\" src=\"//example.com/images/3/3a/Foobar.jpg\" 
height=\"220\" width=\"1941\" 
data-parsoid='{\"a\":{\"resource\":\"./File:Foobar.jpg\",\"height\":\"220\",\"width\":\"1941\"},\"sa\":{\"resource\":\"Image:Foobar.jpg\"}}'/></a><figcaption
 data-parsoid='{\"dsr\":[null,40,null,null]}'>Title</figcaption></figure>");
-add("wt2html", "Manually-specified thumbnail image with explicit link to wiki 
page", "<figure class=\"mw-default-size\" typeof=\"mw:Image\" 
data-parsoid='{\"optList\":[{\"ck\":\"manualthumb\",\"ak\":\"thumb=Thumb.png\"},{\"ck\":\"link\",\"ak\":\"link=Main
 Page\"},{\"ck\":\"caption\",\"ak\":\"Title\"}],\"dsr\":[0,57,2,2]}'><a 
href=\"./Main_Page\" 
data-parsoid='{\"a\":{\"href\":\"./Main_Page\"},\"sa\":{\"href\":\"link=Main 
Page\"},\"dsr\":[2,null,null,null]}'><img resource=\"./File:Foobar.jpg\" 
src=\"//example.com/images/3/3a/Foobar.jpg\" height=\"220\" width=\"1941\" 
data-parsoid='{\"a\":{\"resource\":\"./File:Foobar.jpg\",\"height\":\"220\",\"width\":\"1941\"},\"sa\":{\"resource\":\"Image:Foobar.jpg\"}}'/></a><figcaption
 data-parsoid='{\"dsr\":[null,55,null,null]}'>Title</figcaption></figure>");
-add("wt2html", "Manually-specified thumbnail image with explicit link to url", 
"<figure class=\"mw-default-size\" typeof=\"mw:Image\" 
data-parsoid='{\"optList\":[{\"ck\":\"manualthumb\",\"ak\":\"thumb=Thumb.png\"},{\"ck\":\"link\",\"ak\":\"link=http://example.com\"},{\"ck\":\"caption\",\"ak\":\"Title\"}],\"dsr\":[0,66,2,2]}'><a
 href=\"http://example.com\"; data-parsoid='{\"dsr\":[2,null,null,null]}'><img 
resource=\"./File:Foobar.jpg\" src=\"//example.com/images/3/3a/Foobar.jpg\" 
height=\"220\" width=\"1941\" 
data-parsoid='{\"a\":{\"resource\":\"./File:Foobar.jpg\",\"height\":\"220\",\"width\":\"1941\"},\"sa\":{\"resource\":\"Image:Foobar.jpg\"}}'/></a><figcaption
 data-parsoid='{\"dsr\":[null,64,null,null]}'>Title</figcaption></figure>");
-add("wt2html", "Manually-specified thumbnail image with explicit no link", 
"<figure class=\"mw-default-size\" typeof=\"mw:Image\" 
data-parsoid='{\"optList\":[{\"ck\":\"manualthumb\",\"ak\":\"thumb=Thumb.png\"},{\"ck\":\"link\",\"ak\":\"link=\"},{\"ck\":\"caption\",\"ak\":\"Title\"}],\"dsr\":[0,48,2,2]}'><span
 data-parsoid='{\"dsr\":[2,null,null,null]}'><img 
resource=\"./File:Foobar.jpg\" src=\"//example.com/images/3/3a/Foobar.jpg\" 
height=\"220\" width=\"1941\" 
data-parsoid='{\"a\":{\"resource\":\"./File:Foobar.jpg\",\"height\":\"220\",\"width\":\"1941\"},\"sa\":{\"resource\":\"Image:Foobar.jpg\"}}'/></span><figcaption
 data-parsoid='{\"dsr\":[null,46,null,null]}'>Title</figcaption></figure>");
-add("wt2html", "Manually-specified thumbnail image with explicit link and alt 
text", "<figure class=\"mw-default-size\" typeof=\"mw:Image\" 
data-parsoid='{\"optList\":[{\"ck\":\"manualthumb\",\"ak\":\"thumb=Thumb.png\"},{\"ck\":\"link\",\"ak\":\"link=Main
 
Page\"},{\"ck\":\"alt\",\"ak\":\"alt=alttext\"},{\"ck\":\"caption\",\"ak\":\"Title\"}],\"dsr\":[0,69,2,2]}'><a
 href=\"./Main_Page\" 
data-parsoid='{\"a\":{\"href\":\"./Main_Page\"},\"sa\":{\"href\":\"link=Main 
Page\"},\"dsr\":[2,null,null,null]}'><img alt=\"alttext\" 
resource=\"./File:Foobar.jpg\" src=\"//example.com/images/3/3a/Foobar.jpg\" 
height=\"220\" width=\"1941\" 
data-parsoid='{\"a\":{\"alt\":\"alttext\",\"resource\":\"./File:Foobar.jpg\",\"height\":\"220\",\"width\":\"1941\"},\"sa\":{\"alt\":\"alt=alttext\",\"resource\":\"Image:Foobar.jpg\"}}'/></a><figcaption
 data-parsoid='{\"dsr\":[null,67,null,null]}'>Title</figcaption></figure>");
 add("wt2html", "SVG thumbnails with no language set", "<figure 
class=\"mw-default-size\" typeof=\"mw:Image/Thumb\" 
data-parsoid='{\"optList\":[{\"ck\":\"thumbnail\",\"ak\":\"thumb\"},{\"ck\":\"caption\",\"ak\":\"caption\"}],\"dsr\":[0,33,2,2]}'><a
 href=\"./File:Foobar.svg\" 
data-parsoid='{\"a\":{\"href\":\"./File:Foobar.svg\"},\"dsr\":[2,null,null,null]}'><img
 resource=\"./File:Foobar.svg\" 
src=\"//example.com/images/thumb/f/ff/Foobar.svg/220px-Foobar.svg\" 
height=\"165\" width=\"220\" 
data-parsoid='{\"a\":{\"resource\":\"./File:Foobar.svg\",\"height\":\"165\",\"width\":\"220\"},\"sa\":{\"resource\":\"File:Foobar.svg\"}}'/></a><figcaption
 data-parsoid='{\"dsr\":[null,31,null,null]}'>caption</figcaption></figure>");
 add("wt2html", "SVG thumbnails with language de", "<figure 
class=\"mw-default-size\" typeof=\"mw:Image/Thumb\" 
data-parsoid='{\"optList\":[{\"ck\":\"thumbnail\",\"ak\":\"thumb\"},{\"ck\":\"caption\",\"ak\":\"caption\"},{\"ck\":\"lang\",\"ak\":\"lang=de\"}],\"dsr\":[0,41,2,2]}'><a
 href=\"./File:Foobar.svg\" 
data-parsoid='{\"a\":{\"href\":\"./File:Foobar.svg\"},\"dsr\":[2,null,null,null]}'><img
 resource=\"./File:Foobar.svg\" 
src=\"//example.com/images/thumb/f/ff/Foobar.svg/220px-Foobar.svg\" lang=\"de\" 
height=\"165\" width=\"220\" 
data-parsoid='{\"a\":{\"resource\":\"./File:Foobar.svg\",\"lang\":\"de\",\"height\":\"165\",\"width\":\"220\"},\"sa\":{\"resource\":\"File:Foobar.svg\",\"lang\":\"lang=de\"}}'/></a><figcaption
 data-parsoid='{\"dsr\":[null,39,null,null]}'>caption</figcaption></figure>");
 add("wt2html", "SVG thumbnails with invalid language code", "<figure 
class=\"mw-default-size\" typeof=\"mw:Image/Thumb\" 
data-parsoid='{\"optList\":[{\"ck\":\"thumbnail\",\"ak\":\"thumb\"},{\"ck\":\"caption\",\"ak\":\"caption\"},{\"ck\":\"lang\",\"ak\":\"lang=invalid.language.code\"}],\"dsr\":[0,60,2,2]}'><a
 href=\"./File:Foobar.svg\" 
data-parsoid='{\"a\":{\"href\":\"./File:Foobar.svg\"},\"dsr\":[2,null,null,null]}'><img
 resource=\"./File:Foobar.svg\" 
src=\"//example.com/images/thumb/f/ff/Foobar.svg/220px-Foobar.svg\" 
lang=\"invalid.language.code\" height=\"165\" width=\"220\" 
data-parsoid='{\"a\":{\"resource\":\"./File:Foobar.svg\",\"lang\":\"invalid.language.code\",\"height\":\"165\",\"width\":\"220\"},\"sa\":{\"resource\":\"File:Foobar.svg\",\"lang\":\"lang=invalid.language.code\"}}'/></a><figcaption
 data-parsoid='{\"dsr\":[null,58,null,null]}'>caption</figcaption></figure>");
@@ -316,7 +311,6 @@
 add("wt2html", "Fuzz testing: Parser14-table", "<h2 
data-parsoid='{\"dsr\":[0,5,2,2]}'>a</h2>\n<table style=\"__TOC__\" 
data-parsoid='{\"autoInsertedEnd\":true,\"dsr\":[6,22,16,0]}'></table>");
 add("wt2html", "Fuzz testing: Parser24", "<p 
data-parsoid='{\"fostered\":true,\"autoInsertedEnd\":true,\"dsr\":[0,0,0,0]}'><span
 typeof=\"mw:Nowiki\" 
data-parsoid='{\"src\":\"{{{\",\"dsr\":[3,6,0,0]}'>{{{</span>|\n<u class=\"|\" 
about=\"#mwt2\" typeof=\"mw:ExpandedAttrs\" 
data-mw='{\"attribs\":[[{\"txt\":\"{{{{SSSll!!!!!!!VVVV)]]][[Special:*xxxxxxx-->}}}}\",\"html\":\"&lt;span
 typeof=\\\"mw:Param\\\" about=\\\"#mwt1\\\" id=\\\"mwt1\\\" 
data-parsoid=\\\"{&amp;quot;src&amp;quot;:&amp;quot;{{{{SSSll!!!!!!!VVVV)]]][[Special:*xxxxxxx-->&lt;noinclude>}}}&amp;quot;,&amp;quot;dsr&amp;quot;:[20,79,null,null]}\\\">{{{{SSSll!!!!!!!VVVV)]]][[Special:*xxxxxxx--&amp;gt;}}}&lt;/span>}\"},{\"html\":\"\"}]]}'
 
data-parsoid='{\"stx\":\"html\",\"a\":{\"{{{{SSSll!!!!!!!VVVV)]]][[Special:*xxxxxxx-->&lt;noinclude>}}}}\":null},\"sa\":{\"{{{{SSSll!!!!!!!VVVV)]]][[Special:*xxxxxxx-->&lt;noinclude>}}}}\":\"\"},\"autoInsertedEnd\":true,\"dsr\":[8,0,74,0]}'>\n<br
 style=\"onmouseover='alert(document.cookie);' \" 
data-parsoid='{\"stx\":\"html\",\"selfClose\":true,\"dsr\":[83,0,53,null]}'/></u></p><p
 
data-parsoid='{\"fostered\":true,\"autoInsertedEnd\":true,\"dsr\":[0,0,0,0]}'><u
 class=\"|\" about=\"#mwt2\" typeof=\"mw:ExpandedAttrs\" 
data-mw='{\"attribs\":[[{\"txt\":\"{{{{SSSll!!!!!!!VVVV)]]][[Special:*xxxxxxx-->}}}}\",\"html\":\"&lt;span
 typeof=\\\"mw:Param\\\" about=\\\"#mwt1\\\" id=\\\"mwt1\\\" 
data-parsoid=\\\"{&amp;quot;src&amp;quot;:&amp;quot;{{{{SSSll!!!!!!!VVVV)]]][[Special:*xxxxxxx-->&lt;noinclude>}}}&amp;quot;,&amp;quot;dsr&amp;quot;:[20,79,null,null]}\\\">{{{{SSSll!!!!!!!VVVV)]]][[Special:*xxxxxxx--&amp;gt;}}}&lt;/span>}\"},{\"html\":\"\"}]]}'
 
data-parsoid='{\"stx\":\"html\",\"a\":{\"{{{{SSSll!!!!!!!VVVV)]]][[Special:*xxxxxxx-->&lt;noinclude>}}}}\":null},\"sa\":{\"{{{{SSSll!!!!!!!VVVV)]]][[Special:*xxxxxxx-->&lt;noinclude>}}}}\":\"\"},\"autoInsertedEnd\":true,\"autoInsertedStart\":true,\"dsr\":[-37,0,0,0]}'>MOVE
 YOUR MOUSE CURSOR OVER THIS TEXT</u></p><table 
data-parsoid='{\"autoInsertedEnd\":true,\"dsr\":[0,177,2,0]}'>\n\n\n\n<tbody 
data-parsoid='{\"dsr\":[176,177,0,0]}'><tr 
data-parsoid='{\"autoInsertedEnd\":true,\"autoInsertedStart\":true,\"dsr\":[176,177,0,0]}'><td
 
data-parsoid='{\"autoInsertedEnd\":true,\"dsr\":[176,177,1,0]}'></td></tr></tbody></table>");
 add("wt2html", "Fuzz testing: Parser25 (bug 6055)", "<p 
data-parsoid='{\"dsr\":[0,110,0,0]}'><span about=\"#mwt1\" typeof=\"mw:Param\" 
data-parsoid='{\"dsr\":[0,26,null,null],\"src\":\"{{{\\n| \\n&lt;LI CLASS=||\\n 
>\\n}}}\"}'></span>blah\" onmouseover=\"alert('hello world');\" 
align=\"left\"<b 
data-parsoid='{\"autoInsertedEnd\":1,\"dsr\":[80,110,3,0]}'>MOVE MOUSE CURSOR 
OVER HERE</b></p>");
-add("wt2html", "Fuzz testing: image with bogus manual thumbnail", "<figure 
class=\"mw-default-size\" typeof=\"mw:Image\" 
data-parsoid='{\"optList\":[{\"ck\":\"manualthumb\",\"ak\":\"thumbnail= 
\"}],\"dsr\":[0,32,2,2]}'><a href=\"./File:Foobar.jpg\" 
data-parsoid='{\"a\":{\"href\":\"./File:Foobar.jpg\"},\"dsr\":[2,30,null,null]}'><img
 resource=\"./File:Foobar.jpg\" src=\"//example.com/images/3/3a/Foobar.jpg\" 
height=\"220\" width=\"1941\" 
data-parsoid='{\"a\":{\"resource\":\"./File:Foobar.jpg\",\"height\":\"220\",\"width\":\"1941\"},\"sa\":{\"resource\":\"Image:foobar.jpg\"}}'/></a></figure>");
 add("wt2html", "Inline HTML vs wiki block nesting", "<p 
data-parsoid='{\"dsr\":[0,17,0,0]}'><b 
data-parsoid='{\"stx\":\"html\",\"autoInsertedEnd\":true,\"dsr\":[0,17,3,0]}'>Bold
 paragraph</b></p><b 
data-parsoid='{\"stx\":\"html\",\"autoInsertedEnd\":true,\"autoInsertedStart\":true,\"dsr\":[17,37,0,0]}'>\n\n<p
 data-parsoid='{\"dsr\":[19,37,0,0]}'>New wiki paragraph</p></b>");
 add("wt2html", "Special page transclusion", "<p 
data-parsoid='{\"dsr\":[0,30,0,0]}'><span typeof=\"mw:Transclusion\" 
about=\"#mwt1\" id=\"mwt1\" 
data-mw='{\"parts\":[{\"template\":{\"target\":{\"wt\":\"Special:Prefixindex/Xyzzyx\",\"function\":\"special\"},\"params\":{},\"i\":0}}]}'
 
data-parsoid='{\"src\":\"{{Special:Prefixindex/Xyzzyx}}\",\"dsr\":[0,30,null,null],\"pi\":[[]]}'>Parser
 function implementation for pf_special missing in Parsoid.</span></p>");
 add("wt2html", "Special page transclusion twice (bug 5021)", "<p 
data-parsoid='{\"dsr\":[0,61,0,0]}'><span typeof=\"mw:Transclusion\" 
about=\"#mwt1\" id=\"mwt1\" 
data-mw='{\"parts\":[{\"template\":{\"target\":{\"wt\":\"Special:Prefixindex/Xyzzyx\",\"function\":\"special\"},\"params\":{},\"i\":0}}]}'
 
data-parsoid='{\"src\":\"{{Special:Prefixindex/Xyzzyx}}\",\"dsr\":[0,30,null,null],\"pi\":[[]]}'>Parser
 function implementation for pf_special missing in Parsoid.</span>\n<span 
typeof=\"mw:Transclusion\" about=\"#mwt2\" id=\"mwt2\" 
data-mw='{\"parts\":[{\"template\":{\"target\":{\"wt\":\"Special:Prefixindex/Xyzzyx\",\"function\":\"special\"},\"params\":{},\"i\":0}}]}'
 data-parsoid='{\"dsr\":[31,61,null,null],\"pi\":[[]]}'>Parser function 
implementation for pf_special missing in Parsoid.</span></p>");
@@ -592,11 +586,6 @@
 add("wt2wt", "Allow empty links in image captions (Bug 60753)", 
"[[File:Foobar.jpg|thumb|Caption 
[[Link1]]\n<nowiki>[[]]</nowiki>\n[[Link2]]\n]]");
 add("wt2wt", "Image with multiple widths -- use last", 
"[[File:Foobar.jpg|300px|caption]]\n");
 add("wt2wt", "Image with multiple alignments -- use first (bug 48664)", 
"[[File:Foobar.jpg|thumb|left|caption]]\n\n[[File:Foobar.jpg|middle|caption]]\n");
-add("wt2wt", "Manually-specified thumbnail image", 
"[[Image:Foobar.jpg|Title]]");
-add("wt2wt", "Manually-specified thumbnail image with explicit link to wiki 
page", "[[Image:Foobar.jpg|link=Main Page|Title]]");
-add("wt2wt", "Manually-specified thumbnail image with explicit link to url", 
"[[Image:Foobar.jpg|link=http://example.com|Title]]");
-add("wt2wt", "Manually-specified thumbnail image with explicit no link", 
"[[Image:Foobar.jpg|link=|Title]]");
-add("wt2wt", "Manually-specified thumbnail image with explicit link and alt 
text", "[[Image:Foobar.jpg|link=Main Page|alt=alttext|Title]]");
 add("wt2wt", "Handling of sections up to level 6 and beyond", "= Level 1 
Heading=\n== Level 2 Heading==\n=== Level 3 Heading===\n==== Level 4 
Heading====\n===== Level 5 Heading=====\n====== Level 6 
Heading======\n======<nowiki>= Level 7 
Heading=</nowiki>======\n======<nowiki>== Level 8 
Heading==</nowiki>======\n======<nowiki>=== Level 9 
Heading===</nowiki>======\n======<nowiki>==== Level 10 
Heading====</nowiki>======\n");
 add("wt2wt", "div with single-quoted attribute", "<div id=\"rock\">HTML 
rocks</div>");
 add("wt2wt", "div with unquoted attribute", "<div id=\"rock\">HTML 
rocks</div>");
@@ -627,7 +616,6 @@
 add("wt2wt", "Fuzz testing: Parser22", "http://===r:::https://b\n\n{|\n|}");
 add("wt2wt", "Fuzz testing: Parser24", "{{{|\n<u class=\"|\" 
{{{{SSSll!!!!!!!VVVV)]]][[Special:*xxxxxxx--><noinclude>}}}}>\n<br 
style=\"onmouseover='alert(document.cookie);' \" />\n\nMOVE YOUR MOUSE CURSOR 
OVER THIS TEXT\n{|\n\n|\n|}");
 add("wt2wt", "Fuzz testing: Parser25 (bug 6055)", "{{{\n| \n<LI CLASS=||\n 
>\n}}}blah\" onmouseover=\"alert('hello world');\" align=\"left\"'''MOVE MOUSE 
CURSOR OVER HERE'''\n");
-add("wt2wt", "Fuzz testing: image with bogus manual thumbnail", 
"[[Image:foobar.jpg]]");
 add("wt2wt", "Inline wiki vs wiki block nesting", "'''Bold paragraph'''\n\nNew 
wiki paragraph\n");
 add("wt2wt", "Mixing markup for italics and bold", 
"'''<nowiki>bold'</nowiki>'''''bold''bolditalics'''''\n");
 add("wt2wt", "5 quotes, code coverage +1 line", "''''''''''\n");
@@ -887,11 +875,6 @@
 add("html2html", "Image with link parameter, wgNoFollowLinks set to false", 
"<p data-parsoid='{\"dsr\":[0,22,0,0]}'><a rel=\"mw:ExtLink\" 
href=\"http://example.com/\"; 
data-parsoid='{\"targetOff\":21,\"contentOffsets\":[21,21],\"dsr\":[0,22,21,1]}'></a></p>\n");
 add("html2html", "Image with link parameter, wgNoFollowDomainExceptions", "<p 
data-parsoid='{\"dsr\":[0,22,0,0]}'><a rel=\"mw:ExtLink\" 
href=\"http://example.com/\"; 
data-parsoid='{\"targetOff\":21,\"contentOffsets\":[21,21],\"dsr\":[0,22,21,1]}'></a></p>\n");
 add("html2html", "Image with link parameter, wgExternalLinkTarget, unnamed 
parameter", "<p data-parsoid='{\"dsr\":[0,79,0,0]}'>&lt;a 
href=\"http://example.com/\"; title=\"Title\" target=\"foobar\" 
rel=\"nofollow\">&lt;/a></p>\n");
-add("html2html", "Manually-specified thumbnail image", "<p 
data-parsoid='{\"dsr\":[0,23,0,0]}'>XXX NOT IMPLEMENTED XXX</p>");
-add("html2html", "Manually-specified thumbnail image with explicit link to 
wiki page", "<p data-parsoid='{\"dsr\":[0,23,0,0]}'>XXX NOT IMPLEMENTED 
XXX</p>");
-add("html2html", "Manually-specified thumbnail image with explicit link to 
url", "<p data-parsoid='{\"dsr\":[0,23,0,0]}'>XXX NOT IMPLEMENTED XXX</p>");
-add("html2html", "Manually-specified thumbnail image with explicit no link", 
"<p data-parsoid='{\"dsr\":[0,23,0,0]}'>XXX NOT IMPLEMENTED XXX</p>");
-add("html2html", "Manually-specified thumbnail image with explicit link and 
alt text", "<p data-parsoid='{\"dsr\":[0,23,0,0]}'>XXX NOT IMPLEMENTED 
XXX</p>");
 add("html2html", "Link to image page- image page normally doesn't exists, 
hence edit link\nAdd test with existing image page\n#<p><a 
href=\"/wiki/File:Test\" title=\"Image:Test\">Image:test</a>", "<p 
data-parsoid='{\"dsr\":[0,125,0,0]}'>&lt;a 
href=\"/index.php?title=File:Test&amp;action=edit&amp;redlink=1\" class=\"new\" 
title=\"File:Test (page does not exist)\">Image:test&lt;/a></p>\n");
 add("html2html", "bug 18784  Link to non-existent image page with caption 
should use caption as link text", "<p 
data-parsoid='{\"dsr\":[0,122,0,0]}'>&lt;a 
href=\"/index.php?title=File:Test&amp;action=edit&amp;redlink=1\" class=\"new\" 
title=\"File:Test (page does not exist)\">caption&lt;/a></p>\n");
 add("html2html", "SVG thumbnails with no language set", "<div class=\"thumb 
tright\" data-parsoid='{\"stx\":\"html\",\"dsr\":[0,244,26,6]}'><div 
class=\"thumbinner\" style=\"width:182px;\" 
data-parsoid='{\"stx\":\"html\",\"dsr\":[26,238,45,6]}'>[/wiki/File:Foobar.svg 
]  <div class=\"thumbcaption\" 
data-parsoid='{\"stx\":\"html\",\"dsr\":[97,232,26,6]}'><div class=\"magnify\" 
data-parsoid='{\"stx\":\"html\",\"dsr\":[123,219,21,6]}'>&lt;a 
href=\"/wiki/File:Foobar.svg\" class=\"internal\" 
title=\"Enlarge\">&lt;/a></div>caption</div></div></div>\n");
@@ -1716,11 +1699,6 @@
 add("html2wt", "Image with link parameter, wgNoFollowLinks set to false", 
"[http://example.com/ ]\n");
 add("html2wt", "Image with link parameter, wgNoFollowDomainExceptions", 
"[http://example.com/ ]\n");
 add("html2wt", "Image with link parameter, wgExternalLinkTarget, unnamed 
parameter", "<a href=\"http://example.com/\"; title=\"Title\" target=\"foobar\" 
rel=\"nofollow\"></a>\n");
-add("html2wt", "Manually-specified thumbnail image", "XXX NOT IMPLEMENTED 
XXX");
-add("html2wt", "Manually-specified thumbnail image with explicit link to wiki 
page", "XXX NOT IMPLEMENTED XXX");
-add("html2wt", "Manually-specified thumbnail image with explicit link to url", 
"XXX NOT IMPLEMENTED XXX");
-add("html2wt", "Manually-specified thumbnail image with explicit no link", 
"XXX NOT IMPLEMENTED XXX");
-add("html2wt", "Manually-specified thumbnail image with explicit link and alt 
text", "XXX NOT IMPLEMENTED XXX");
 add("html2wt", "Link to image page- image page normally doesn't exists, hence 
edit link\nAdd test with existing image page\n#<p><a href=\"/wiki/File:Test\" 
title=\"Image:Test\">Image:test</a>", "<a 
href=\"/index.php?title=File:Test&action=edit&redlink=1\" class=\"new\" 
title=\"File:Test (page does not exist)\">Image:test</a>\n");
 add("html2wt", "bug 18784  Link to non-existent image page with caption should 
use caption as link text", "<a 
href=\"/index.php?title=File:Test&action=edit&redlink=1\" class=\"new\" 
title=\"File:Test (page does not exist)\">caption</a>\n");
 add("html2wt", "SVG thumbnails with no language set", "<div class=\"thumb 
tright\"><div class=\"thumbinner\" 
style=\"width:182px;\">[/wiki/File:Foobar.svg ]  <div 
class=\"thumbcaption\"><div class=\"magnify\"><a href=\"/wiki/File:Foobar.svg\" 
class=\"internal\" title=\"Enlarge\"></a></div>caption</div></div></div>\n");
@@ -1884,7 +1862,6 @@
 add("html2wt", "Fuzz testing: URL adjacent extension (with space, clean)", 
"[http://example.com http://example.com] junk\n");
 add("html2wt", "Fuzz testing: URL adjacent extension (no space, dirty; 
nowiki)", "[http://example.com http://example.com]junk\n";);
 add("html2wt", "Fuzz testing: URL adjacent extension (no space, dirty; pre)", 
"[http://example.com http://example.com]\n junk\n");
-add("html2wt", "Fuzz testing: image with bogus manual thumbnail", "<div 
class=\"thumb tright\"><div class=\"thumbinner\" style=\"width:182px;\">Error 
creating thumbnail:   <div class=\"thumbcaption\"></div></div></div>\n");
 add("html2wt", "Fuzz testing: encoded newline in generated HTML replacements 
(bug 6577)", " \n");
 add("html2wt", "Parsing optional HTML elements (Bug 6171)", "{|\n  \n    | 
Some tabular data\n    | More tabular data ...\n    | And yet som tabular 
data\n  \n|}\n");
 add("html2wt", "Correct handling of <td>, <tr> (Bug 6171)", "{|\n  \n    | 
Some tabular data\n    | More tabular data ...\n    | And yet som tabular 
data\n  \n|}\n");
diff --git a/tests/parserTests.txt b/tests/parserTests.txt
index 9cea156..cc9e939 100644
--- a/tests/parserTests.txt
+++ b/tests/parserTests.txt
@@ -10046,56 +10046,64 @@
 !! test
 Manually-specified thumbnail image
 !! wikitext
-[[Image:Foobar.jpg|thumb=Thumb.png|Title]]
+[[File:Foobar.jpg|thumb=Thumb.png|Title]]
 !! html/php
 <div class="thumb tright"><div class="thumbinner" style="width:137px;"><a 
href="/wiki/File:Foobar.jpg"><img alt="" 
src="http://example.com/images/e/ea/Thumb.png"; width="135" height="135" 
class="thumbimage" /></a>  <div class="thumbcaption"><div class="magnify"><a 
href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img 
src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" 
/></a></div>Title</div></div></div>
 
 !! html/parsoid
-XXX NOT IMPLEMENTED XXX
+<figure class="mw-default-size" typeof="mw:Image/Thumb" 
data-mw='{"thumb":"Thumb.png"}'><a href="File:Foobar.jpg"><img 
resource="./File:Foobar.jpg" src="//example.com/images/e/ea/Thumb.png" 
height="135" width="135"/></a><figcaption>Title</figcaption></figure>
 !! end
 
 !! test
 Manually-specified thumbnail image with explicit link to wiki page
+!! options
+parsoid=wt2html,wt2wt,html2html
 !! wikitext
-[[Image:Foobar.jpg|thumb=Thumb.png|link=Main Page|Title]]
+[[File:Foobar.jpg|thumb=Thumb.png|link=Main_Page|Title]]
 !! html/php
 <div class="thumb tright"><div class="thumbinner" style="width:137px;"><a 
href="/wiki/Main_Page" title="Main Page"><img alt="" 
src="http://example.com/images/e/ea/Thumb.png"; width="135" height="135" 
class="thumbimage" /></a>  <div class="thumbcaption"><div class="magnify"><a 
href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img 
src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" 
/></a></div>Title</div></div></div>
 
 !! html/parsoid
-XXX NOT IMPLEMENTED XXX
+<figure class="mw-default-size" typeof="mw:Image/Thumb" 
data-mw='{"thumb":"Thumb.png"}'><a href="Main_Page"><img 
resource="./File:Foobar.jpg" src="//example.com/images/e/ea/Thumb.png" 
height="135" width="135"/></a><figcaption>Title</figcaption></figure>
 !! end
 
 !! test
 Manually-specified thumbnail image with explicit link to url
+!! options
+parsoid=wt2html,wt2wt,html2html
 !! wikitext
-[[Image:Foobar.jpg|thumb=Thumb.png|link=http://example.com|Title]]
+[[File:Foobar.jpg|thumb=Thumb.png|link=http://example.com|Title]]
 !! html/php
 <div class="thumb tright"><div class="thumbinner" style="width:137px;"><a 
href="http://example.com";><img alt="" 
src="http://example.com/images/e/ea/Thumb.png"; width="135" height="135" 
class="thumbimage" /></a>  <div class="thumbcaption"><div class="magnify"><a 
href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img 
src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" 
/></a></div>Title</div></div></div>
 
 !! html/parsoid
-XXX NOT IMPLEMENTED XXX
+<figure class="mw-default-size" typeof="mw:Image/Thumb" 
data-mw='{"thumb":"Thumb.png"}'><a href="http://example.com";><img 
resource="./File:Foobar.jpg" src="//example.com/images/e/ea/Thumb.png" 
height="135" width="135"/></a><figcaption>Title</figcaption></figure>
 !! end
 
 !! test
 Manually-specified thumbnail image with explicit no link
+!! options
+parsoid=wt2html,wt2wt,html2html
 !! wikitext
-[[Image:Foobar.jpg|thumb=Thumb.png|link=|Title]]
+[[File:Foobar.jpg|thumb=Thumb.png|link=|Title]]
 !! html/php
 <div class="thumb tright"><div class="thumbinner" style="width:137px;"><img 
alt="" src="http://example.com/images/e/ea/Thumb.png"; width="135" height="135" 
class="thumbimage" />  <div class="thumbcaption"><div class="magnify"><a 
href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img 
src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" 
/></a></div>Title</div></div></div>
 
 !! html/parsoid
-XXX NOT IMPLEMENTED XXX
+<figure class="mw-default-size" typeof="mw:Image/Thumb" 
data-mw='{"thumb":"Thumb.png"}'><span><img resource="./File:Foobar.jpg" 
src="//example.com/images/e/ea/Thumb.png" height="135" 
width="135"/></span><figcaption>Title</figcaption></figure>
 !! end
 
 !! test
 Manually-specified thumbnail image with explicit link and alt text
+!! options
+parsoid=wt2html,wt2wt,html2html
 !! wikitext
-[[Image:Foobar.jpg|thumb=Thumb.png|link=Main Page|alt=alttext|Title]]
+[[File:Foobar.jpg|thumb=Thumb.png|link=Main_Page|alt=alttext|Title]]
 !! html/php
 <div class="thumb tright"><div class="thumbinner" style="width:137px;"><a 
href="/wiki/Main_Page" title="Main Page"><img alt="alttext" 
src="http://example.com/images/e/ea/Thumb.png"; width="135" height="135" 
class="thumbimage" /></a>  <div class="thumbcaption"><div class="magnify"><a 
href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img 
src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" 
/></a></div>Title</div></div></div>
 
 !! html/parsoid
-XXX NOT IMPLEMENTED XXX
+<figure class="mw-default-size" typeof="mw:Image/Thumb" 
data-mw='{"thumb":"Thumb.png"}'><a href="Main_Page"><img alt="alttext" 
resource="./File:Foobar.jpg" src="//example.com/images/e/ea/Thumb.png" 
height="135" width="135"/></a><figcaption>Title</figcaption></figure>
 !! end
 
 !! test
@@ -13278,9 +13286,11 @@
 Fuzz testing: image with bogus manual thumbnail
 !! wikitext
 [[Image:foobar.jpg|thumbnail= ]]
-!! html
+!! html/php
 <div class="thumb tright"><div class="thumbinner" style="width:182px;">Error 
creating thumbnail:   <div class="thumbcaption"></div></div></div>
 
+!! html/parsoid
+<meta typeof="mw:Placeholder" 
data-parsoid='{"src":"[[Image:foobar.jpg|thumbnail= 
]]","optList":[{"ck":"manualthumb","ak":"thumbnail= 
"}],"dsr":[0,32,null,null]}'/>
 !!end
 
 !! test

-- 
To view, visit https://gerrit.wikimedia.org/r/103360
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I91d170aa4f6d1fd844d24ccb85b886eb079e3e2a
Gerrit-PatchSet: 11
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Cscott <[email protected]>
Gerrit-Reviewer: GWicke <[email protected]>
Gerrit-Reviewer: Subramanya Sastry <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to