From 853af2d848eba7198dbd139a191c8739c68179f1 Mon Sep 17 00:00:00 2001 From: lin onetwo Date: Sat, 18 Apr 2026 16:59:22 +0800 Subject: [PATCH] Fix: limit macro call parser to need >> to work, prevent > in regex (#9813) * fix: limit macro call parser to need >> to work, prevent > in regex * test: add malformed macro parameter regression coverage The parser fix on this branch only changes parseMacroParameterAsAttribute() when an unquoted value starts with <<, so the previous broader parser tests did not prove the regression. Add a focused structural test that fails without the guard and passes with it. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus * Revert "fix: limit macro call parser to need >> to work, prevent > in regex" This reverts commit f96b0629026178400ead4cf5d49356dd7ea9f589. * lint: test * Reapply "fix: limit macro call parser to need >> to work, prevent > in regex" This reverts commit 075f7cc2825eb6de63ffd8f1b291fc4d06e538fc. --------- Co-authored-by: Sisyphus --- core/modules/parsers/parseutils.js | 2 +- editions/test/tiddlers/tests/test-wikitext-parser.js | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/core/modules/parsers/parseutils.js b/core/modules/parsers/parseutils.js index 06254ee69..53dfc48c0 100644 --- a/core/modules/parsers/parseutils.js +++ b/core/modules/parsers/parseutils.js @@ -327,7 +327,7 @@ exports.parseMacroParameterAsAttribute = function(source,pos) { // Define our regexps var reAttributeName = /([^\/\s>"'`=:]+)/y, reStrictIdentifier = /^[A-Za-z0-9\-_]+$/, - reUnquotedAttribute = /((?:(?:>(?!>))|[^\s>"'])+)/y, + reUnquotedAttribute = /(?!<<)((?:(?:>(?!>))|[^\s>"'])+)/y, reFilteredValue = /\{\{\{([\S\s]+?)\}\}\}/y, reIndirectValue = /\{\{([^\}]+)\}\}/y, reSubstitutedValue = /(?:```([\s\S]*?)```|`([^`]|[\S\s]*?)`)/y; diff --git a/editions/test/tiddlers/tests/test-wikitext-parser.js b/editions/test/tiddlers/tests/test-wikitext-parser.js index 2808c91de..a821e8588 100644 --- a/editions/test/tiddlers/tests/test-wikitext-parser.js +++ b/editions/test/tiddlers/tests/test-wikitext-parser.js @@ -468,5 +468,9 @@ describe("WikiText parser tests", function() { expect(parse(wikitext)).toEqual(expectedParseTree); }); -}); + it("should reject unquoted macro parameter values that start with <<", function() { + var attribute = $tw.utils.parseMacroParameterAsAttribute("d=< />",0); + expect(attribute).toBeNull(); + }); +});