Fix problem with tiddler titled "undefined"

Fixes #2507

The problem stems from a JavaScript quirk: the fact that
`({“undefined":"Me"})[undefined]` returns “Me”. The quirk is that the
value `undefined` is coerced into the string “undefined” when used as
an index.

In this particular case, the code for `wiki.getTiddler()` was returning
the tiddler with the title `”undefined”` when called with the title set
to the value `undefined`. It happens that the pluginswitcher called
`wiki.getTiddler(undefined)`.
print-window-tiddler
Jermolene 2016-07-22 11:31:02 +01:00
rodzic 487d6642e3
commit e282ff1d92
1 zmienionych plików z 7 dodań i 6 usunięć

Wyświetl plik

@ -913,12 +913,13 @@ $tw.Wiki = function(options) {
// Get a tiddler from the store
this.getTiddler = function(title) {
var t = tiddlers[title];
if(t instanceof $tw.Tiddler) {
return t;
} else if(title !== undefined && Object.prototype.hasOwnProperty.call(shadowTiddlers,title)) {
return shadowTiddlers[title].tiddler;
} else {
if(title) {
var t = tiddlers[title];
if(t instanceof $tw.Tiddler) {
return t;
} else if(title !== undefined && Object.prototype.hasOwnProperty.call(shadowTiddlers,title)) {
return shadowTiddlers[title].tiddler;
}
return undefined;
}
};