Cscott has uploaded a new change for review. https://gerrit.wikimedia.org/r/284232
Change subject: Resolve titles even when $wgArticlePath involves a query string. ...................................................................... Resolve titles even when $wgArticlePath involves a query string. Change-Id: Idf9018f54ee741f3db6ec4f54d8087a8d5a17d84 --- M lib/parsoid.js 1 file changed, 13 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Collection/OfflineContentGenerator/bundler refs/changes/32/284232/1 diff --git a/lib/parsoid.js b/lib/parsoid.js index a48c006..06f6a53 100644 --- a/lib/parsoid.js +++ b/lib/parsoid.js @@ -37,7 +37,8 @@ this.document = domino.createDocument(text); // Create a regexp that matches the article path in order to resolve URLs // into titles. - var m = /^([\s\S]*)\$1([\s\S]*)$/.exec(siteinfo.general.articlepath); + this.articlepath = siteinfo.general.articlepath; + var m = /^([\s\S]*)\$1([\s\S]*)$/.exec(this.articlepath); this._resolveRE = new RegExp( '^' + escapeRegExp(m[1]) + '([\\s\\S]*)' + escapeRegExp(m[2]) + '$' ); @@ -45,11 +46,21 @@ // Resolve an article title. ParsoidResult.prototype._resolve = function(href) { + if (/\?/.test(this.articlepath)) { + // Fall back to old-style stripping + return decodeURIComponent(href.replace(/^(..?\/)*/, '')); + } + // Resolve to an absolute URL var path = url.parse(url.resolve(this.getBaseHref(), href), false, true). pathname; // Now remove the articlepath. var m = this._resolveRE.exec(path); - if (!m) { throw new Error('Bad article title: ' + href); } + if (!m) { + throw new Error( + '$wgArticlePath is set incorrectly: ' + + this.articlepath + ' ' + this.getBaseHref() + ' ' + href + ); + } return decodeURIComponent(m[1]); }; -- To view, visit https://gerrit.wikimedia.org/r/284232 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Idf9018f54ee741f3db6ec4f54d8087a8d5a17d84 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Collection/OfflineContentGenerator/bundler Gerrit-Branch: master Gerrit-Owner: Cscott <canan...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits