mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-11-08 19:43:34 +00:00
Fixed issue: deprecated regexp could cause crash (#6438)
* Fixed issue: deprecated regexp could cause crash * Different fix which will bother plugins less
This commit is contained in:
@@ -95,10 +95,12 @@ function parseFilterOperation(operators,filterString,p) {
|
|||||||
if(nextBracketPos === -1) {
|
if(nextBracketPos === -1) {
|
||||||
throw "Missing closing bracket in filter expression";
|
throw "Missing closing bracket in filter expression";
|
||||||
}
|
}
|
||||||
if(!operator.regexp) {
|
if(operator.regexp) {
|
||||||
|
operand.text = "";
|
||||||
|
} else {
|
||||||
operand.text = filterString.substring(p,nextBracketPos);
|
operand.text = filterString.substring(p,nextBracketPos);
|
||||||
operator.operands.push(operand);
|
|
||||||
}
|
}
|
||||||
|
operator.operands.push(operand);
|
||||||
p = nextBracketPos + 1;
|
p = nextBracketPos + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -256,6 +256,16 @@ Tests the filtering mechanism.
|
|||||||
expect(wiki.filterTiddlers("[modifier/Jo/]").join(",")).toBe("TiddlerOne,$:/TiddlerTwo,Tiddler Three,a fourth tiddler,one");
|
expect(wiki.filterTiddlers("[modifier/Jo/]").join(",")).toBe("TiddlerOne,$:/TiddlerTwo,Tiddler Three,a fourth tiddler,one");
|
||||||
expect(console.log).toHaveBeenCalledWith("WARNING: Filter", "modifier", "has a deprecated regexp operand", /Jo/);
|
expect(console.log).toHaveBeenCalledWith("WARNING: Filter", "modifier", "has a deprecated regexp operand", /Jo/);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should handle regular expression operands without crashing", function() {
|
||||||
|
spyOn(console, 'log');
|
||||||
|
// We don't really care about the results. Just don't get RSoD.
|
||||||
|
expect(() => wiki.filterTiddlers("[all/current/]")).not.toThrow();
|
||||||
|
expect(() => wiki.filterTiddlers("[prefix/anything/]")).not.toThrow();
|
||||||
|
expect(() => wiki.filterTiddlers("[title/anything/]")).not.toThrow();
|
||||||
|
expect(() => wiki.filterTiddlers("[/anything/]")).not.toThrow();
|
||||||
|
expect(() => wiki.filterTiddlers("[//]")).not.toThrow();
|
||||||
|
});
|
||||||
|
|
||||||
it("should handle the prefix operator", function() {
|
it("should handle the prefix operator", function() {
|
||||||
expect(wiki.filterTiddlers("[prefix[Tiddler]]").join(",")).toBe("TiddlerOne,Tiddler Three");
|
expect(wiki.filterTiddlers("[prefix[Tiddler]]").join(",")).toBe("TiddlerOne,Tiddler Three");
|
||||||
|
|||||||
Reference in New Issue
Block a user