jenkins-bot has submitted this change and it was merged. Change subject: Lint images with bogus options ......................................................................
Lint images with bogus options Change-Id: I99d926066f5139bbd8f8066f351ee59bf492db7a --- M lib/dom.linter.js M tests/mocha/lintertest.js 2 files changed, 32 insertions(+), 0 deletions(-) Approvals: Subramanya Sastry: Looks good to me, approved jenkins-bot: Verified diff --git a/lib/dom.linter.js b/lib/dom.linter.js index d23670b..61a95f3 100644 --- a/lib/dom.linter.js +++ b/lib/dom.linter.js @@ -181,6 +181,26 @@ } } +/* +* +* Log Bogus Image Options, since with unrecognized image options +* See - https://www.mediawiki.org/wiki/Help:Images#Syntax +* +*/ +function logBogusImageOptions(env, c) { + + if(DU.isGeneratedFigure(c)) { + var optlist = DU.getDataParsoid(c).optList; + optlist.forEach(function (item) { + if (item.ck === "bogus") { + var dsr = DU.getDataParsoid(c).dsr; + env.log('lint/BogusImageOptions', env.page.src, dsr); + } + }); + } +} + + function logWikitextFixups(node, env) { var c = node.firstChild; @@ -218,6 +238,9 @@ // Log obsolete HTML tags logObsoleteHTMLTags(env, c); + // Log bogus image options + logBogusImageOptions(env, c); + } c = nextSibling; diff --git a/tests/mocha/lintertest.js b/tests/mocha/lintertest.js index 91f00b6..5c15951 100644 --- a/tests/mocha/lintertest.js +++ b/tests/mocha/lintertest.js @@ -97,5 +97,14 @@ result[0].should.have.a.property("src", "|- foo\n|bar"); }); }); + it( 'should lint Bogus image options correctly', function() { + return parseWT( '[[file:a.jpg|foo|bar]]' ).then( function ( result ) { + result.should.have.length( 1 ); + result[0].should.have.a.property( "type", "BogusImageOptions" ); + result[0].should.have.a.property( "wiki", "enwiki" ); + result[0].dsr.should.include.members( [ 0, 22, null, null ] ); + result[0].should.have.a.property( "src", "[[file:a.jpg|foo|bar]]" ); + }); + }); }); }); -- To view, visit https://gerrit.wikimedia.org/r/144068 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I99d926066f5139bbd8f8066f351ee59bf492db7a Gerrit-PatchSet: 4 Gerrit-Project: mediawiki/services/parsoid Gerrit-Branch: master Gerrit-Owner: Hardikj <hardikjuneja...@gmail.com> Gerrit-Reviewer: Cscott <canan...@wikimedia.org> Gerrit-Reviewer: Hardikj <hardikjuneja...@gmail.com> Gerrit-Reviewer: Subramanya Sastry <ssas...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits