mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-12-08 01:38:06 +00:00
Adds $tw.utils.decodeURISafe and $tw.utils.decodeURIComponentSafe (#5999)
* call self.displayError
* Revert "call self.displayError"
This reverts commit 5d599aa979.
* fixes decodeURI & decodeURIComponent
This commit is contained in:
@@ -164,7 +164,7 @@ var importDataTypes = [
|
||||
}},
|
||||
{type: "URL", IECompatible: true, toTiddlerFieldsArray: function(data,fallbackTitle) {
|
||||
// Check for tiddler data URI
|
||||
var match = decodeURIComponent(data).match(/^data\:text\/vnd\.tiddler,(.*)/i);
|
||||
var match = $tw.utils.decodeURIComponentSafe(data).match(/^data\:text\/vnd\.tiddler,(.*)/i);
|
||||
if(match) {
|
||||
return parseJSONTiddlers(match[1],fallbackTitle);
|
||||
} else {
|
||||
@@ -173,7 +173,7 @@ var importDataTypes = [
|
||||
}},
|
||||
{type: "text/x-moz-url", IECompatible: false, toTiddlerFieldsArray: function(data,fallbackTitle) {
|
||||
// Check for tiddler data URI
|
||||
var match = decodeURIComponent(data).match(/^data\:text\/vnd\.tiddler,(.*)/i);
|
||||
var match = $tw.utils.decodeURIComponentSafe(data).match(/^data\:text\/vnd\.tiddler,(.*)/i);
|
||||
if(match) {
|
||||
return parseJSONTiddlers(match[1],fallbackTitle);
|
||||
} else {
|
||||
|
||||
@@ -969,4 +969,22 @@ exports.makeCompareFunction = function(type,options) {
|
||||
return (types[type] || types[options.defaultType] || types.number);
|
||||
};
|
||||
|
||||
exports.decodeURIComponentSafe = function(str) {
|
||||
var value = str;
|
||||
try {
|
||||
value = decodeURIComponent(str);
|
||||
} catch(e) {
|
||||
}
|
||||
return value;
|
||||
};
|
||||
|
||||
exports.decodeURISafe = function(str) {
|
||||
var value = str;
|
||||
try {
|
||||
value = decodeURI(str);
|
||||
} catch(e) {
|
||||
}
|
||||
return value;
|
||||
};
|
||||
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user