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 commitf96b062902. * lint: test * Reapply "fix: limit macro call parser to need >> to work, prevent > in regex" This reverts commit075f7cc282. --------- Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -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();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user