Arlolra has uploaded a new change for review. https://gerrit.wikimedia.org/r/235668
Change subject: Fix logic in hasWikitextTokens when asking for linksOnly ...................................................................... Fix logic in hasWikitextTokens when asking for linksOnly * I'm assuming this `linksOnly` flag means that the test only cares about link tokens. * The early return meant that if another type of SelfclosingTagTk was encountered, it would return false. And yes, we do have other types in the tokenizer. * There seems to be another bug here which isn't addressed in that it'll only return true for wikilinks with valid targets. But, what about extlinks? Change-Id: Id70219ab27c32e28886407f979f907230bfbf42d --- M lib/wts.escapeWikitext.js 1 file changed, 13 insertions(+), 3 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/parsoid refs/changes/68/235668/1 diff --git a/lib/wts.escapeWikitext.js b/lib/wts.escapeWikitext.js index 0f18fc6..a03a0a2 100644 --- a/lib/wts.escapeWikitext.js +++ b/lib/wts.escapeWikitext.js @@ -243,6 +243,10 @@ // Ignore non-whitelisted html tags if (t.isHTMLTag()) { + if (linksOnly) { + continue; + } + if (/(?:^|\s)mw:Extension(?=$|\s)/.test(t.getAttribute("typeof")) && options.extName !== t.getAttribute("name")) { return true; @@ -307,14 +311,20 @@ } } - return !linksOnly; + if (!linksOnly) { + return true; + } + } + + if (linksOnly) { + continue; } if (state.inCaption && tc === pd.TagTk && t.name === 'listItem') { continue; } - if (!linksOnly && tc === pd.TagTk) { + if (tc === pd.TagTk) { var ttype = t.getAttribute('typeof'); // Ignore mw:Entity tokens if (t.name === 'span' && ttype === 'mw:Entity') { @@ -342,7 +352,7 @@ return true; } - if (!linksOnly && tc === pd.EndTagTk) { + if (tc === pd.EndTagTk) { // Ignore mw:Entity tokens if (numEntities > 0 && t.name === 'span') { numEntities--; -- To view, visit https://gerrit.wikimedia.org/r/235668 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Id70219ab27c32e28886407f979f907230bfbf42d Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/services/parsoid Gerrit-Branch: master Gerrit-Owner: Arlolra <abrea...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits