aboutsummaryrefslogtreecommitdiffstats
path: root/lang/js
diff options
context:
space:
mode:
authorMaximilian Krambach <[email protected]>2018-08-27 11:00:50 +0000
committerMaximilian Krambach <[email protected]>2018-08-27 11:00:50 +0000
commit28086252f15e2c124a2a00c2abc87a815d227fbe (patch)
tree6c312fda6556bd4fee66b96a6de3a24eeb5f9de3 /lang/js
parentjs: typecheck destructured parameters (diff)
downloadgpgme-28086252f15e2c124a2a00c2abc87a815d227fbe.tar.gz
gpgme-28086252f15e2c124a2a00c2abc87a815d227fbe.zip
js: make non-payload data more encoding-tolerant
-- * src/Helpers.js: As non-payload data might come in different encodings, a conversion has been introduced that worked in most cases. Data like the userid might come in different encodings, which we don't know of. For now, a try..catch returns the data as they are if the utf-8 decoding fails. Sometimes this yields the correct result, sometimes it may not work, but it won't stop the whole operation anymore.
Diffstat (limited to 'lang/js')
-rw-r--r--lang/js/src/Helpers.js9
1 files changed, 8 insertions, 1 deletions
diff --git a/lang/js/src/Helpers.js b/lang/js/src/Helpers.js
index 9fa5775b..aa267f69 100644
--- a/lang/js/src/Helpers.js
+++ b/lang/js/src/Helpers.js
@@ -115,7 +115,14 @@ export function isLongId (value){
*/
export function decode (property){
if (typeof property === 'string'){
- return decodeURIComponent(escape(property));
+ try {
+ return decodeURIComponent(escape(property));
+ }
+ catch (error){
+ if (error instanceof URIError) {
+ return property;
+ }
+ }
} else if (Array.isArray(property)){
let res = [];
for (let arr=0; arr < property.length; arr++){