mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-12-24 00:50:28 +00:00
Fix action-listops unsafe use of $tw.utils.stringifyList() (#6540)
Fixes #6535
This commit is contained in:
parent
c1f123499c
commit
b0c4886d23
@ -1,3 +1,5 @@
|
||||
const { makeTiddlerIterator } = require("../wiki");
|
||||
|
||||
/*\
|
||||
title: $:/core/modules/widgets/action-listops.js
|
||||
type: application/javascript
|
||||
@ -71,8 +73,8 @@ ActionListopsWidget.prototype.invokeAction = function(triggeringWidget,
|
||||
}
|
||||
if(this.subfilter) {
|
||||
var inputList = this.wiki.getTiddlerList(this.target,field,index),
|
||||
subfilter = $tw.utils.stringifyList(inputList) + " " + this.subfilter;
|
||||
this.wiki.setText(this.target, field, index, $tw.utils.stringifyList(this.wiki.filterTiddlers(subfilter,this)));
|
||||
subfilter = "[all[]] " + this.subfilter;
|
||||
this.wiki.setText(this.target, field, index, $tw.utils.stringifyList(this.wiki.filterTiddlers(subfilter,this,this.wiki.makeTiddlerIterator(inputList))));
|
||||
}
|
||||
if(this.filtertags) {
|
||||
var tiddler = this.wiki.getTiddler(this.target),
|
||||
|
55
editions/test/tiddlers/tests/test-action-widgets.js
Normal file
55
editions/test/tiddlers/tests/test-action-widgets.js
Normal file
@ -0,0 +1,55 @@
|
||||
/*\
|
||||
title: test-action-widgets.js
|
||||
type: application/javascript
|
||||
tags: [[$:/tags/test-spec]]
|
||||
|
||||
Tests the action widgets.
|
||||
|
||||
\*/
|
||||
(function(){
|
||||
|
||||
/* jslint node: true, browser: true */
|
||||
/* eslint-env node, browser, jasmine */
|
||||
/* eslint no-mixed-spaces-and-tabs: ["error", "smart-tabs"]*/
|
||||
/* global $tw, require */
|
||||
"use strict";
|
||||
|
||||
describe("Action widget tests", function() {
|
||||
|
||||
function setupWiki(wikiOptions) {
|
||||
wikiOptions = wikiOptions || {};
|
||||
// Create a wiki
|
||||
var wiki = new $tw.Wiki(wikiOptions);
|
||||
var tiddlers = [{
|
||||
title: "Root",
|
||||
text: "Some dummy content"
|
||||
}];
|
||||
wiki.addTiddlers(tiddlers);
|
||||
wiki.addIndexersToWiki();
|
||||
var widgetNode = wiki.makeTranscludeWidget("Root",{document: $tw.fakeDocument, parseAsInline: true});
|
||||
var container = $tw.fakeDocument.createElement("div");
|
||||
widgetNode.render(container,null);
|
||||
return {
|
||||
wiki: wiki,
|
||||
widgetNode: widgetNode,
|
||||
contaienr: container
|
||||
};
|
||||
}
|
||||
|
||||
it("should handle the action-listops widget", function() {
|
||||
var info = setupWiki();
|
||||
var invokeActions = function(actions) {
|
||||
info.widgetNode.invokeActionString(actions,info.widgetNode,null,{});
|
||||
};
|
||||
invokeActions("<$action-setfield $tiddler='Output' $field='text' $value='Elephants!'/>");
|
||||
expect(info.wiki.getTiddlerText("Output")).toBe("Elephants!");
|
||||
invokeActions("<$action-listops $tiddler='Output' $field='text' $subfilter='+[toggle[-3]]'/>");
|
||||
expect(info.wiki.getTiddlerText("Output")).toBe("Elephants! -3");
|
||||
invokeActions("<$action-listops $tiddler='Output' $field='text' $subfilter='+[toggle[-3]]'/>");
|
||||
expect(info.wiki.getTiddlerText("Output")).toBe("Elephants!");
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
})();
|
||||
|
Loading…
Reference in New Issue
Block a user