Skip to content

Commit 51cb811

Browse files
authored
Merge pull request #179 from perfectapi/fix-encoding-dropbox-again
Fix encoding dropbox again
2 parents 0820ccd + c518be9 commit 51cb811

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

manifest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "CKP - KeePass integration for Chrome™",
33
"short_name": "CKP Extension",
4-
"version": "2017.5.29",
4+
"version": "2017.5.30",
55
"manifest_version": 2,
66
"minimum_chrome_version": "48",
77

services/dropboxFileManager.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,15 @@ function DropboxFileManager($http, settings) {
116116
}
117117
}
118118

119+
function http_header_safe_json(v) {
120+
var charsToEncode = /[\u007f-\uffff]/g;
121+
return JSON.stringify(v).replace(charsToEncode,
122+
function(c) {
123+
return '\\u' + ('000' + c.charCodeAt(0).toString(16)).slice(-4);
124+
}
125+
);
126+
}
127+
119128
//given minimal file information, retrieve the actual file
120129
function getChosenDatabaseFile(dbInfo) {
121130
return getToken().then(function(accessToken) {
@@ -128,7 +137,7 @@ function DropboxFileManager($http, settings) {
128137
responseType: 'arraybuffer',
129138
headers: {
130139
'Authorization': 'Bearer ' + accessToken,
131-
'Dropbox-API-Arg': JSON.stringify(arg)
140+
'Dropbox-API-Arg': http_header_safe_json(arg)
132141
}
133142
})
134143
}).then(function(response) {

0 commit comments

Comments
 (0)