1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2026-05-28 00:02:17 +00:00

Restore v5.3.8 handling of malformed attribute syntax (#9812)

Also add a bunch of tests

Fixes #9808
This commit is contained in:
Jeremy Ruston
2026-04-18 09:56:22 +01:00
committed by GitHub
parent 2f63abc12a
commit 2c1cb33081
19 changed files with 251 additions and 0 deletions
+3
View File
@@ -576,6 +576,9 @@ exports.parseAttribute = function(source,pos) {
pos = unquotedValue.end;
node.type = "string";
node.value = unquotedValue.match[1];
} else if(source.charAt(pos) === "<" && source.charAt(pos + 1) === "<" && source.indexOf(">>",pos) !== -1) {
// Value looks like a macro invocation (starts with << with a closing >> ahead) but does not parse as one. Return null so the enclosing tag fails to parse rather than silently binding the attribute to "true" and treating the remainder as further attributes (restores v5.3.8 behaviour)
return null;
} else {
node.type = "string";
node.value = "true";
@@ -0,0 +1,13 @@
title: Parse/BackCompat/MacrocallColonNamed
description: Macrocall named-parameter syntax using colon continues to work
type: text/vnd.tiddlywiki-multiple
tags: [[$:/tags/wiki-test-spec]]
title: Output
\define x(d) got=$d$
<<x d:"hi">>
+
title: ExpectedResult
<p>got=hi</p>
@@ -0,0 +1,13 @@
title: Parse/BackCompat/MacrocallColonNonStrict
description: Colon-separator requires a strict identifier name; otherwise value is treated as positional (fix #9788)
type: text/vnd.tiddlywiki-multiple
tags: [[$:/tags/wiki-test-spec]]
title: Output
\define x(d) got=$d$
<<x $:/a:"v">>
+
title: ExpectedResult
<p>got=<a class="tc-tiddlylink tc-tiddlylink-missing" href="#%24%3A%2Fa">$:/a</a>:</p>
@@ -0,0 +1,13 @@
title: Parse/BackCompat/MacrocallEqualsNoValue
description: Macrocall named parameter with =-separator but no value fails to parse the macro call
type: text/vnd.tiddlywiki-multiple
tags: [[$:/tags/wiki-test-spec]]
title: Output
\define x(d) got=$d$
<<x d=>>
+
title: ExpectedResult
<p>&lt;<x d="true">&gt;</x></p>
@@ -0,0 +1,13 @@
title: Parse/BackCompat/MacrocallNamedEquals
description: Macrocall attribute with =-separator (restored compact call syntax, v5.3.9+)
type: text/vnd.tiddlywiki-multiple
tags: [[$:/tags/wiki-test-spec]]
title: Output
\define x(d) got=$d$
<<x d="hello">>
+
title: ExpectedResult
<p>got=hello</p>
@@ -0,0 +1,13 @@
title: Parse/BackCompat/MacrocallFilteredValue
description: Macrocall attribute value can be a filtered value {{{...}}}
type: text/vnd.tiddlywiki-multiple
tags: [[$:/tags/wiki-test-spec]]
title: Output
\define x(d) got=$d$
<<x d={{{[[hi]]}}}>>
+
title: ExpectedResult
<p>got=hi</p>
@@ -0,0 +1,17 @@
title: Parse/BackCompat/MacrocallIndirectValue
description: Macrocall attribute value can be an indirect value {{tid!!field}}
type: text/vnd.tiddlywiki-multiple
tags: [[$:/tags/wiki-test-spec]]
title: Output
\define x(d) got=$d$
<<x d={{Other!!foo}}>>
+
title: ExpectedResult
<p>got=FROM-OTHER</p>
+
title: Other
foo: FROM-OTHER
@@ -0,0 +1,14 @@
title: Parse/BackCompat/MacrocallMvvValue
description: Macrocall attribute value can be an MVV reference ((v))
type: text/vnd.tiddlywiki-multiple
tags: [[$:/tags/wiki-test-spec]]
title: Output
\define d() DEFD
\define x(d) got=$d$
<<x d=((d))>>
+
title: ExpectedResult
<p>got=DEFD</p>
@@ -0,0 +1,14 @@
title: Parse/BackCompat/MacrocallNestedMacroValue
description: Macrocall attribute value can be a nested macro invocation
type: text/vnd.tiddlywiki-multiple
tags: [[$:/tags/wiki-test-spec]]
title: Output
\define d() DEFD
\define x(d) got=$d$
<<x d=<<d>>>>
+
title: ExpectedResult
<p>got=DEFD</p>
@@ -0,0 +1,13 @@
title: Parse/BackCompat/MacrocallSubstitutedValue
description: Macrocall attribute value can be a substituted value `...`
type: text/vnd.tiddlywiki-multiple
tags: [[$:/tags/wiki-test-spec]]
title: Output
\define x(d) got=$d$
<<x d=`hi`>>
+
title: ExpectedResult
<p>got=hi</p>
@@ -0,0 +1,13 @@
title: Parse/BackCompat/MacrocallPositionalGt
description: Bare > (not followed by >) is permitted in unquoted macrocall positional params
type: text/vnd.tiddlywiki-multiple
tags: [[$:/tags/wiki-test-spec]]
title: Output
\define x(d) got=$d$
<<x foo>val>>
+
title: ExpectedResult
<p>got=foo&gt;val</p>
@@ -0,0 +1,17 @@
title: Parse/BackCompat/MalformedMultiLineTerminator
description: When << value looks like a macro invocation but fails to parse, the enclosing widget tag must fail cleanly so the remainder of the document is not silently reinterpreted (the v5.4 strict parser previously collapsed to attribute="true" and swallowed subsequent lines as stray attributes)
type: text/vnd.tiddlywiki-multiple
tags: [[$:/tags/wiki-test-spec]]
title: Output
\define d() DEFD
\define x(d) got=$d$
<$macrocall $name="x" d=<<d> />
<$macrocall $name="x" d=<<d> />
>>
+
title: ExpectedResult
<p>&lt;$macrocall $name="x" d=&lt;<d> /&gt;
&lt;$macrocall $name="x" d=DEFD</d></p>
@@ -0,0 +1,14 @@
title: Parse/BackCompat/QuotedGtInNestedMacro
description: Nested macro invocation in widget attribute can contain > in quoted inner attribute values
type: text/vnd.tiddlywiki-multiple
tags: [[$:/tags/wiki-test-spec]]
title: Output
\define d() DEFD
\define x(d) got=$d$
<$macrocall $name="x" d=<<d b="x>y">> />
+
title: ExpectedResult
<p>got=DEFD</p>
@@ -0,0 +1,14 @@
title: Parse/BackCompat/MalformedNoTerminator
description: Widget attribute value starting with << but with no >> ahead falls through to "true" (matches v5.3.8)
type: text/vnd.tiddlywiki-multiple
tags: [[$:/tags/wiki-test-spec]]
title: Output
\define d() DEFD
\define x(d) got=$d$
<$macrocall $name="x" d=<<d> />
+
title: ExpectedResult
<p>got=true</p>
@@ -0,0 +1,14 @@
title: Parse/BackCompat/ValidNestedMacro
description: Widget attribute value with well-formed nested macro invocation
type: text/vnd.tiddlywiki-multiple
tags: [[$:/tags/wiki-test-spec]]
title: Output
\define d() DEFD
\define x(d) got=$d$
<$macrocall $name="x" d=<<d>> />
+
title: ExpectedResult
<p>got=DEFD</p>
@@ -0,0 +1,13 @@
title: Parse/BackCompat/WidgetAttrEqualsNoValue
description: Widget attribute with trailing equals and no value falls through to "true"
type: text/vnd.tiddlywiki-multiple
tags: [[$:/tags/wiki-test-spec]]
title: Output
\define x(d) got=$d$
<$macrocall $name="x" d= />
+
title: ExpectedResult
<p>got=true</p>
@@ -0,0 +1,13 @@
title: Parse/BackCompat/WidgetAttrMalformedMvv
description: Widget attribute value with unclosed ((v) falls through to a string literal
type: text/vnd.tiddlywiki-multiple
tags: [[$:/tags/wiki-test-spec]]
title: Output
\define x(d) got=$d$
<$macrocall $name="x" d=((d) />
+
title: ExpectedResult
<p>got=((d)</p>
@@ -0,0 +1,14 @@
title: Parse/BackCompat/WidgetAttrMvvValue
description: Widget attribute value can be an MVV reference ((v))
type: text/vnd.tiddlywiki-multiple
tags: [[$:/tags/wiki-test-spec]]
title: Output
\define d() DEFD
\define x(d) got=$d$
<$macrocall $name="x" d=((d)) />
+
title: ExpectedResult
<p>got=DEFD</p>
@@ -0,0 +1,13 @@
title: Parse/BackCompat/WidgetAttrSubstitutedValue
description: Widget attribute value can be a substituted value `...`
type: text/vnd.tiddlywiki-multiple
tags: [[$:/tags/wiki-test-spec]]
title: Output
\define x(d) got=$d$
<$macrocall $name="x" d=`hi` />
+
title: ExpectedResult
<p>got=hi</p>