GWicke has uploaded a new change for review. https://gerrit.wikimedia.org/r/117211
Change subject: Bug 61298: Avoid need for cloning when using PHP preprocessor ...................................................................... Bug 61298: Avoid need for cloning when using PHP preprocessor Template parameters were processed asynchronously even when using the PHP preprocessor. This is however not necessary, as all template parameters encountered in that situation are undefined. External link contents are parsed all the way to DOM to avoid them breaking up the link. This includes sanitization, which destructively updates the tokens (removes attributes). Combined with asynchronous parameter processing this lead to the crash observed in bug 61298. Change-Id: I5296fab7a0a3010a024a5765cd72d10102f4ba4b Co-authored-by: Arlo Breault <abrea...@wikimedia.org> Co-authored-by: Gabriel Wicke <gwi...@wikimedia.org> --- M lib/ext.core.Sanitizer.js M lib/ext.core.TemplateHandler.js 2 files changed, 13 insertions(+), 6 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/parsoid refs/changes/11/117211/1 diff --git a/lib/ext.core.Sanitizer.js b/lib/ext.core.Sanitizer.js index df72edb..ea81662 100644 --- a/lib/ext.core.Sanitizer.js +++ b/lib/ext.core.Sanitizer.js @@ -732,11 +732,6 @@ // XXX: Likely better done in AttributeTransformManager when processing is // complete if (attribs && attribs.length > 0) { - // FIXME: There's still some token sharing going on and templates - // contained in templates end up getting attributes stripped. - // This is #61298. - token = token.clone(); - // is this an htmlpre? var p = token.getAttribute( "property" ); var htmlpre = token.name === "pre" && p && p.match( /^mw:html$/ ); diff --git a/lib/ext.core.TemplateHandler.js b/lib/ext.core.TemplateHandler.js index 45ec4e1..6fb25d9 100644 --- a/lib/ext.core.TemplateHandler.js +++ b/lib/ext.core.TemplateHandler.js @@ -940,7 +940,19 @@ } else { newCB = cb; } - this.fetchArg(attribs[0].k, this.lookupArg.bind(this, args, attribs, newCB, cb), cb); + if (this.manager.env.conf.parsoid.usePHPPreProcessor) { + // When using the PHP preprocessor this template parameter can only be + // at the top level, where no template parameters are defined. So + // return just the source and encapsulate it for round-tripping. + // + // Without async operations here we also avoid issues like + // the token sharing encountered in bug 61298 when tokens are also + // processed all the way to DOM which involves destructive + // modifications of tokens in the sanitizer. + newCB({tokens:[token.dataAttribs.src]}); + } else { + this.fetchArg(attribs[0].k, this.lookupArg.bind(this, args, attribs, newCB, cb), cb); + } }; TemplateHandler.prototype.fetchArg = function(arg, argCB, asyncCB) { -- To view, visit https://gerrit.wikimedia.org/r/117211 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I5296fab7a0a3010a024a5765cd72d10102f4ba4b Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/services/parsoid Gerrit-Branch: master Gerrit-Owner: GWicke <gwi...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits