mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-23 10:07:19 +00:00
* Fix Bug #7054: Reuse of $:/core/ui/EditTemplate/fields broken This fixes Bug #7054 by creating a new variable `safeNewFieldValueTiddlerPrefix` that is always set to a valid, temporary prefix. This variable is used within `$action-deletetiddler`. If the passed `newFieldValueTiddlerPrefix` variable is empty a new prefix will be generated by the same logic that creates the original `newFieldValueTiddlerPrefix` variable. To be even more defensive, the prefix-filter was prepended with another prefix filter that limits matches to `$:/temp/NewFieldValue`. This prevents a bogus but non empty value in `newFieldValueTiddlerPrefix` to delete arbitrary tiddlers. * Add a default for `newFieldValueTiddlerPrefix` This fixes a problem that was identified while fixing bug #7054. If the tiddler `$:/core/ui/EditTemplate/fields` is transcluded directly and `newFieldValueTiddlerPrefix` is not set, it will be generated. This makes sure that this value is defined. It can not be redefined unconditionally because if this tiddler is transcluded from `EditTemplate.tid` these two tiddlers must agree on the same prefix because the clean-up is duplicated between `EditTemplate.tid` and `fields.tid`. This would make `safeNewFieldValueTiddlerPrefix` obsolete, but I leave it in there to make the macros safe and prevent any problems if the `newFieldValueTiddlerPrefix` is unset by a later change.
This commit is contained in:
parent
10bb3ba09d
commit
80442b7f7f
@ -1,7 +1,12 @@
|
||||
title: $:/core/ui/EditTemplate
|
||||
|
||||
\define delete-edittemplate-state-tiddlers() <$action-deletetiddler $filter="[<newFieldNameTiddler>] [prefix<newFieldValueTiddlerPrefix>] [<newFieldNameInputTiddler>] [<newFieldNameSelectionTiddler>] [<newTagNameTiddler>] [<newTagNameInputTiddler>] [<newTagNameSelectionTiddler>] [<typeInputTiddler>] [<typeSelectionTiddler>]"/>
|
||||
\define delete-edittemplate-state-tiddlers()
|
||||
<$set name="safeNewFieldValueTiddlerPrefix" value=<<newFieldValueTiddlerPrefix>> emptyValue=<<qualify "$:/temp/NewFieldValue">> >
|
||||
<$action-deletetiddler $filter="[<newFieldNameTiddler>] [prefix[$:/temp/NewFieldValue]prefix<safeNewFieldValueTiddlerPrefix>] [<newFieldNameInputTiddler>] [<newFieldNameSelectionTiddler>] [<newTagNameTiddler>] [<newTagNameInputTiddler>] [<newTagNameSelectionTiddler>] [<typeInputTiddler>] [<typeSelectionTiddler>]"/>
|
||||
</$set>
|
||||
\end
|
||||
|
||||
<!-- Beware this is duplicated from fields.tid. For details see bug #7054 -->
|
||||
\define get-field-value-tiddler-filter() [subfilter<get-field-editor-filter>sha256[16]addprefix[/]addprefix<newFieldValueTiddlerPrefix>]
|
||||
\define get-field-editor-filter() [<newFieldNameTiddler>get[text]else[]] :cascade[all[shadows+tiddlers]tag[$:/tags/FieldEditorFilter]!is[draft]get[text]] :and[!is[blank]else{$:/core/ui/EditTemplate/fieldEditor/default}]
|
||||
|
||||
|
@ -10,6 +10,10 @@ $:/config/EditTemplateFields/Visibility/$(currentField)$
|
||||
[[hide]] -[title{$(config-title)$}]
|
||||
\end
|
||||
|
||||
<!-- Beware this is duplicated from EditTemplate.tid. For details see bug #7054 -->
|
||||
\define get-field-value-tiddler-filter() [subfilter<get-field-editor-filter>sha256[16]addprefix[/]addprefix<newFieldValueTiddlerPrefix>]
|
||||
\define get-field-editor-filter() [<newFieldNameTiddler>get[text]else[]] :cascade[all[shadows+tiddlers]tag[$:/tags/FieldEditorFilter]!is[draft]get[text]] :and[!is[blank]else{$:/core/ui/EditTemplate/fieldEditor/default}]
|
||||
|
||||
\define current-tiddler-new-field-selector()
|
||||
[data-tiddler-title="$(currentTiddlerCSSescaped)$"] .tc-edit-field-add-name-wrapper input
|
||||
\end
|
||||
@ -17,7 +21,9 @@ $:/config/EditTemplateFields/Visibility/$(currentField)$
|
||||
\define new-field-actions()
|
||||
\whitespace trim
|
||||
<$action-sendmessage $message="tm-add-field" $name={{{ [<newFieldNameTiddler>get[text]] }}} $value={{{ [<newFieldNameTiddler>get[text]] :map[subfilter<get-field-value-tiddler-filter>get[text]] }}}/>
|
||||
<$action-deletetiddler $filter="[<newFieldNameTiddler>] [prefix<newFieldValueTiddlerPrefix>] [<storeTitle>] [<searchListState>]"/>
|
||||
<$set name="safeNewFieldValueTiddlerPrefix" value=<<newFieldValueTiddlerPrefix>> emptyValue=<<qualify "$:/temp/NewFieldValue">> >
|
||||
<$action-deletetiddler $filter="[<newFieldNameTiddler>] [prefix[$:/temp/NewFieldValue]prefix<safeNewFieldValueTiddlerPrefix>] [<storeTitle>] [<searchListState>]"/>
|
||||
</$set>
|
||||
<$action-sendmessage $message="tm-focus-selector" $param=<<current-tiddler-new-field-selector>>/>
|
||||
\end
|
||||
|
||||
@ -52,7 +58,9 @@ $:/config/EditTemplateFields/Visibility/$(currentField)$
|
||||
<$action-sendmessage $message="tm-add-field"
|
||||
$name=<<name>>
|
||||
$value={{{ [subfilter<get-field-value-tiddler-filter>get[text]] }}}/>
|
||||
<$action-deletetiddler $filter="[<newFieldNameTiddler>] [prefix<newFieldValueTiddlerPrefix>] [<storeTitle>] [<searchListState>]"/>
|
||||
<$set name="safeNewFieldValueTiddlerPrefix" value=<<newFieldValueTiddlerPrefix>> emptyValue=<<qualify "$:/temp/NewFieldValue">> >
|
||||
<$action-deletetiddler $filter="[<newFieldNameTiddler>] [prefix[$:/temp/NewFieldValue]prefix<safeNewFieldValueTiddlerPrefix>] [<storeTitle>] [<searchListState>]"/>
|
||||
</$set>
|
||||
<<lingo Fields/Add/Button>>
|
||||
</$button>
|
||||
</$reveal>
|
||||
@ -65,6 +73,7 @@ $value={{{ [subfilter<get-field-value-tiddler-filter>get[text]] }}}/>
|
||||
\end
|
||||
\whitespace trim
|
||||
|
||||
<$set name="newFieldValueTiddlerPrefix" value=<<newFieldValueTiddlerPrefix>> emptyValue=<<qualify "$:/temp/NewFieldValue">> >
|
||||
<div class="tc-edit-fields">
|
||||
<table class={{{ [all[current]fields[]] :filter[lookup[$:/config/EditTemplateFields/Visibility/]!match[hide]] +[count[]!match[0]] +[then[tc-edit-fields]] ~[[tc-edit-fields tc-edit-fields-small]] }}}>
|
||||
<tbody>
|
||||
@ -148,3 +157,4 @@ $value={{{ [subfilter<get-field-value-tiddler-filter>get[text]] }}}/>
|
||||
</$vars>
|
||||
</div>
|
||||
</$fieldmangler>
|
||||
</$set>
|
Loading…
Reference in New Issue
Block a user