Skip to content

Commit

Permalink
Fix further crashes from non-string template targets
Browse files Browse the repository at this point in the history
 * Follow up to 5608e83, where the possiblity of a non-string first
   token was anticipated.

 * Renders /am.wikipedia.org/v3/page/html/መለጠፊያ%3AIf/89130

Change-Id: I119953e4e2541be99e987a4126c9c0f1c1204359
  • Loading branch information
arlolra authored and jenkins-bot committed Sep 14, 2017
1 parent fd4dc93 commit bcd5572
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions lib/wt2html/tt/TemplateHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -481,13 +481,19 @@ TemplateHandler.prototype.resolveTemplateTarget = function(state, targetToks) {
// Strip ":" after skipping empty tokens, if any
if (isPF) {
while (firstTok === '') {
firstTok = targetToks[0]; // FIXME: Isn't guaranteed to be a string
firstTok = targetToks[0];
targetToks = targetToks.slice(1);
}
console.assert(firstTok[0] === ':', 'Expecting : in parser function definiton');
firstTok = firstTok.slice(1);
if (typeof firstTok === 'string') {
console.assert(firstTok[0] === ':', 'Expecting : in parser function definiton');
pfArgToks = [firstTok.slice(1)].concat(targetToks);
} else {
// FIXME: Again, protect from crashers. See below.
pfArgToks = targetToks;
}
} else {
pfArgToks = [firstTok].concat(targetToks);
}
pfArgToks = [firstTok].concat(targetToks);
} else {
// FIXME: In the scenario where the target itself is not a string,
// protect from crashers by using the full token -- this is still
Expand Down

0 comments on commit bcd5572

Please sign in to comment.