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:
Joshua Fontany
2021-08-29 13:39:32 +01:00
committed by GitHub
parent a67b1b8bb5
commit 33eef0202d
17 changed files with 41 additions and 33 deletions
+2 -2
View File
@@ -149,7 +149,7 @@ function convertNodes(remarkableTree, isStartOfInline) {
out.push({
type: "link",
attributes: {
to: { type: "string", value: decodeURI(currentNode.href.substr(1)) }
to: { type: "string", value: $tw.utils.decodeURISafe(currentNode.href.substr(1)) }
},
children: children
});
@@ -180,7 +180,7 @@ function convertNodes(remarkableTree, isStartOfInline) {
type: "image",
attributes: {
tooltip: { type: "string", value: currentNode.alt },
source: { type: "string", value: decodeURIComponent(currentNode.src) }
source: { type: "string", value: $tw.utils.decodeURIComponentSafe(currentNode.src) }
}
});
break;
+1 -1
View File
@@ -17,7 +17,7 @@ var rawHash = document.location.hash.substring(1);
if(rawHash.charAt(0) === "#") {
var hash;
try{
hash = decodeURIComponent(rawHash.substring(1));
hash = $tw.utils.decodeURIComponentSafe(rawHash.substring(1));
} catch(ex) {
console.log("Share plugin: Error decoding location hash",ex);
}
@@ -346,8 +346,8 @@ TiddlyWebAdaptor.prototype.parseEtag = function(etag) {
return null;
} else {
return {
bag: decodeURIComponent(etag.substring(1,firstSlash)),
title: decodeURIComponent(etag.substring(firstSlash + 1,lastSlash)),
bag: $tw.utils.decodeURIComponentSafe(etag.substring(1,firstSlash)),
title: $tw.utils.decodeURIComponentSafe(etag.substring(firstSlash + 1,lastSlash)),
revision: etag.substring(lastSlash + 1,colon)
};
}