From 28f90a289347a1fa9b6fd0f817aa272e0b8c67bc Mon Sep 17 00:00:00 2001 From: ansuz Date: Tue, 9 May 2017 11:51:32 +0200 Subject: [PATCH 1/4] document nginx config changes --- example.nginx.conf | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/example.nginx.conf b/example.nginx.conf index 5067ca9c0..fcb8b7435 100644 --- a/example.nginx.conf +++ b/example.nginx.conf @@ -32,7 +32,7 @@ server { set $scriptSrc "'self'"; set $connectSrc "'self' wss://cryptpad.fr wss://api.cryptpad.fr"; set $fontSrc "'self'"; - set $imgSrc "data: *"; + set $imgSrc "data: * blob:"; set $frameSrc "'self' beta.cryptpad.fr"; if ($uri = /pad/inner.html) { @@ -65,8 +65,12 @@ server { rewrite ^.*$ /customize/api/config break; } + location ^~ /blob/ { + try_files $uri =404; + } + ## TODO fix in the code so that we don't need this - location ~ ^/(register|login|settings|user|pad|drive|poll|slide|code|whiteboard)$ { + location ~ ^/(register|login|settings|user|pad|drive|poll|slide|code|whiteboard|file|media)$ { rewrite ^(.*)$ $1/ redirect; } From 4a104052b40f8310961390d922b6cf7773f51a3d Mon Sep 17 00:00:00 2001 From: ansuz Date: Tue, 9 May 2017 11:55:25 +0200 Subject: [PATCH 2/4] handle errors in file --- www/file/main.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/www/file/main.js b/www/file/main.js index 7e193e6a9..ac5acdc84 100644 --- a/www/file/main.js +++ b/www/file/main.js @@ -89,6 +89,7 @@ define([ var newU8 = FileCrypto.joinChunks(chunks); FileCrypto.decrypt(newU8, key, function (e, res) { + if (e) { return console.error(e); } var title = document.title = res.metadata.name; myFile = res.content; myDataType = res.metadata.type; @@ -218,12 +219,15 @@ define([ var key = Nacl.util.decodeBase64(cryptKey); FileCrypto.decrypt(u8, key, function (e, data) { + if (e) { + Cryptpad.removeLoadingScreen(); + return console.error(e); + } console.log(data); var title = document.title = data.metadata.name; myFile = data.content; myDataType = data.metadata.type; updateTitle(title || defaultName); - Cryptpad.removeLoadingScreen(); }); }); From ce5cdce917b00df444f0c4cf7c954992d094bbb5 Mon Sep 17 00:00:00 2001 From: yflory Date: Tue, 9 May 2017 14:31:28 +0200 Subject: [PATCH 3/4] Fix an issue where the username was lost on websocket reconnect --- www/common/common-userlist.js | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/www/common/common-userlist.js b/www/common/common-userlist.js index 8ba7b31e1..7b62d6566 100644 --- a/www/common/common-userlist.js +++ b/www/common/common-userlist.js @@ -7,14 +7,16 @@ define(function () { var userData = exp.userData = {}; var userList = exp.userList = info.userList; var myData = exp.myData = {}; - var myUserName = exp.myUserName = info.myID; - var myNetfluxId = exp.myNetfluxId = info.myID; + exp.myUserName = info.myID; + exp.myNetfluxId = info.myID; + + var network = Cryptpad.getNetwork(); var parsed = Cryptpad.parsePadUrl(window.location.href); var appType = parsed ? parsed.type : undefined; - var users = userList.users; var addToUserData = exp.addToUserData = function(data) { + var users = userList.users; for (var attrname in data) { userData[attrname] = data[attrname]; } if (users && users.length) { @@ -34,7 +36,7 @@ define(function () { return { data: userData, list: userList, - userNetfluxId: myNetfluxId + userNetfluxId: exp.myNetfluxId }; }; @@ -44,13 +46,14 @@ define(function () { if(myUserNameTemp.length > 32) { myUserNameTemp = myUserNameTemp.substr(0, 32); } - myUserName = myUserNameTemp; - myData[myNetfluxId] = { - name: myUserName, + exp.myUserName = myUserNameTemp; + myData = {}; + myData[exp.myNetfluxId] = { + name: exp.myUserName, uid: Cryptpad.getUid(), }; addToUserData(myData); - Cryptpad.setAttribute('username', myUserName, function (err) { + Cryptpad.setAttribute('username', exp.myUserName, function (err) { if (err) { console.log("Couldn't set username"); console.error(err); @@ -72,7 +75,7 @@ define(function () { if (typeof(lastName) === 'string') { setName(lastName, onLocal); } else { - myData[myNetfluxId] = { + myData[exp.myNetfluxId] = { name: "", uid: Cryptpad.getUid(), }; @@ -90,6 +93,11 @@ define(function () { setName(newName, onLocal); }); + network.on('reconnect', function (uid) { + exp.myNetfluxId = uid; + exp.setName(exp.myUserName); + }); + return exp; }; From ae7d65c3fa6a89f5b0022aa2fd083c2beebce94f Mon Sep 17 00:00:00 2001 From: ansuz Date: Tue, 9 May 2017 15:11:27 +0200 Subject: [PATCH 4/4] fix drag to select in chrome --- www/drive/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/drive/main.js b/www/drive/main.js index 1788a7e1c..39b5450fc 100644 --- a/www/drive/main.js +++ b/www/drive/main.js @@ -2369,7 +2369,7 @@ define([ module.hideMenu(); }); - $appContainer.on('click', function (e) { + $appContainer.on('mousedown', function (e) { if (e.which !== 1) { return ; } removeSelected(e); removeInput();