1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2026-06-06 20:52:17 +00:00

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 <clio-agent@sisyphuslabs.ai>

* Revert "fix: limit macro call parser to need >> to work, prevent > in regex"

This reverts commit f96b062902.

* lint: test

* Reapply "fix: limit macro call parser to need >> to work, prevent > in regex"

This reverts commit 075f7cc282.

---------

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
lin onetwo
2026-04-18 16:59:22 +08:00
committed by GitHub
parent 2c1cb33081
commit 853af2d848
2 changed files with 6 additions and 2 deletions
+1 -1
View File
@@ -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;
@@ -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=<<d> />",0);
expect(attribute).toBeNull();
});
});