diff --git a/core/modules/parsers/parseutils.js b/core/modules/parsers/parseutils.js index 1c7525588..925674056 100644 --- a/core/modules/parsers/parseutils.js +++ b/core/modules/parsers/parseutils.js @@ -84,8 +84,7 @@ exports.parseTokenString = function(source,pos,token) { }; /* -Look for a token matching a regex at a specified position. Returns null if not found, otherwise returns {type: "regexp", match:, start:, end:,} -Use the "Y" (sticky) flag to avoid searching the entire rest of the string +Look for a token matching a regex. Returns null if not found, otherwise returns {type: "regexp", match:, start:, end:,} */ exports.parseTokenRegExp = function(source,pos,reToken) { var node = { @@ -146,7 +145,7 @@ exports.parseMacroParameter = function(source,pos) { start: pos }; // Define our regexp - var reMacroParameter = /(?:([A-Za-z0-9\-_]+)\s*:)?(?:\s*(?:"""([\s\S]*?)"""|"([^"]*)"|'([^']*)'|\[\[([^\]]*)\]\]|((?:(?:>(?!>))|[^\s>"'])+)))/y; + var reMacroParameter = /(?:([A-Za-z0-9\-_]+)\s*:)?(?:\s*(?:"""([\s\S]*?)"""|"([^"]*)"|'([^']*)'|\[\[([^\]]*)\]\]|((?:(?:>(?!>))|[^\s>"'])+)))/g; // Skip whitespace pos = $tw.utils.skipWhiteSpace(source,pos); // Look for the parameter @@ -185,7 +184,7 @@ exports.parseMacroInvocation = function(source,pos) { params: [] }; // Define our regexps - var reMacroName = /([^\s>"'=]+)/y; + var reMacroName = /([^\s>"'=]+)/g; // Skip whitespace pos = $tw.utils.skipWhiteSpace(source,pos); // Look for a double less than sign @@ -222,7 +221,7 @@ exports.parseFilterVariable = function(source) { params: [], }, pos = 0, - reName = /([^\s"']+)/y; + reName = /([^\s"']+)/g; // If there is no whitespace or it is an empty string then there are no macro parameters if(/^\S*$/.test(source)) { node.name = source; @@ -247,10 +246,10 @@ exports.parseAttribute = function(source,pos) { start: pos }; // Define our regexps - var reAttributeName = /([^\/\s>"'=]+)/y, - reUnquotedAttribute = /([^\/\s<>"'=]+)/y, - reFilteredValue = /\{\{\{([\S\s]+?)\}\}\}/y, - reIndirectValue = /\{\{([^\}]+)\}\}/y; + var reAttributeName = /([^\/\s>"'=]+)/g, + reUnquotedAttribute = /([^\/\s<>"'=]+)/g, + reFilteredValue = /\{\{\{([\S\s]+?)\}\}\}/g, + reIndirectValue = /\{\{([^\}]+)\}\}/g; // Skip whitespace pos = $tw.utils.skipWhiteSpace(source,pos); // Get the attribute name diff --git a/core/modules/parsers/wikiparser/rules/html.js b/core/modules/parsers/wikiparser/rules/html.js index fdaae03ba..7fc4bb96e 100644 --- a/core/modules/parsers/wikiparser/rules/html.js +++ b/core/modules/parsers/wikiparser/rules/html.js @@ -48,7 +48,7 @@ exports.parse = function() { // Advance the parser position to past the tag this.parser.pos = tag.end; // Check for an immediately following double linebreak - var hasLineBreak = !tag.isSelfClosing && !!$tw.utils.parseTokenRegExp(this.parser.source,this.parser.pos,/([^\S\n\r]*\r?\n(?:[^\S\n\r]*\r?\n|$))/y); + var hasLineBreak = !tag.isSelfClosing && !!$tw.utils.parseTokenRegExp(this.parser.source,this.parser.pos,/([^\S\n\r]*\r?\n(?:[^\S\n\r]*\r?\n|$))/g); // Set whether we're in block mode tag.isBlock = this.is.block || hasLineBreak; // Parse the body if we need to @@ -78,7 +78,7 @@ exports.parseTag = function(source,pos,options) { orderedAttributes: [] }; // Define our regexps - var reTagName = /([a-zA-Z0-9\-\$]+)/y; + var reTagName = /([a-zA-Z0-9\-\$]+)/g; // Skip whitespace pos = $tw.utils.skipWhiteSpace(source,pos); // Look for a less than sign @@ -129,7 +129,7 @@ exports.parseTag = function(source,pos,options) { pos = token.end; // Check for a required line break if(options.requireLineBreak) { - token = $tw.utils.parseTokenRegExp(source,pos,/([^\S\n\r]*\r?\n(?:[^\S\n\r]*\r?\n|$))/y); + token = $tw.utils.parseTokenRegExp(source,pos,/([^\S\n\r]*\r?\n(?:[^\S\n\r]*\r?\n|$))/g); if(!token) { return null; } diff --git a/core/modules/parsers/wikiparser/rules/image.js b/core/modules/parsers/wikiparser/rules/image.js index 9bfce99d2..6b379d9c5 100644 --- a/core/modules/parsers/wikiparser/rules/image.js +++ b/core/modules/parsers/wikiparser/rules/image.js @@ -116,7 +116,7 @@ exports.parseImage = function(source,pos) { // Skip whitespace pos = $tw.utils.skipWhiteSpace(source,pos); // Get the source up to the terminating `]]` - token = $tw.utils.parseTokenRegExp(source,pos,/(?:([^|\]]*?)\|)?([^\]]+?)\]\]/y); + token = $tw.utils.parseTokenRegExp(source,pos,/(?:([^|\]]*?)\|)?([^\]]+?)\]\]/g); if(!token) { return null; }