1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2026-05-06 21:51:31 +00:00

Compare commits

...

1 Commits

Author SHA1 Message Date
Jeremy Ruston
0539edcb54 Restore v5.3.8 handling of malformed attribute syntax
Also add a bunch of tests

Fixes #9808
2026-04-16 15:35:04 +01:00
19 changed files with 251 additions and 0 deletions

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";

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>