From 215bd4e015f3069e007c14ab57937d0eade7ba88 Mon Sep 17 00:00:00 2001 From: Robin Munn Date: Wed, 15 Nov 2023 05:10:58 +0700 Subject: [PATCH] Avoid skipping extra whitespace in wikiparser.js (#7835) When wikiparser parses text looking for a pragma block, it skips whitespace before looking for the next pragma. If no pragma is found, we should return the parse position to the original location so that the skipped whitespace can be parsed as a text node. This allows the attribute `join=" and "` to parse as " and " rather than "and ". --- core/modules/parsers/wikiparser/wikiparser.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/modules/parsers/wikiparser/wikiparser.js b/core/modules/parsers/wikiparser/wikiparser.js index 293b7d3d3..1606d982d 100644 --- a/core/modules/parsers/wikiparser/wikiparser.js +++ b/core/modules/parsers/wikiparser/wikiparser.js @@ -194,6 +194,7 @@ Parse any pragmas at the beginning of a block of parse text WikiParser.prototype.parsePragmas = function() { var currentTreeBranch = this.tree; while(true) { + var savedPos = this.pos; // Skip whitespace this.skipWhitespace(); // Check for the end of the text @@ -204,6 +205,7 @@ WikiParser.prototype.parsePragmas = function() { var nextMatch = this.findNextMatch(this.pragmaRules,this.pos); // If not, just exit if(!nextMatch || nextMatch.matchIndex !== this.pos) { + this.pos = savedPos; break; } // Process the pragma rule