diff options
author | Stefan <stefan@stefans-entwicklerecke.de> | 2017-07-30 11:49:29 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-30 11:49:29 +0200 |
commit | f6456c0aa71f7d232e96db5b95ef4e1d3317e749 (patch) | |
tree | f9fc7cb63b4d072ed347da3db6965da64ae164fb | |
parent | 5382b06ede7cd27c97df669e06379c7547a898e9 (diff) | |
parent | c959cdbaa7a59ffe594710b2c86c369d55817385 (diff) | |
download | etherpad-lite-f6456c0aa71f7d232e96db5b95ef4e1d3317e749.zip |
Merge pull request #3187 from tiblu/ep_prefs_different_cookie_for_different_protocol
#3179 - Using EP on same domain, but over different protocols causes "Warning: it appears that your browser does not have cookies enabled.
-rw-r--r-- | src/static/js/pad.js | 2 | ||||
-rw-r--r-- | src/static/js/pad_cookie.js | 9 |
2 files changed, 8 insertions, 3 deletions
diff --git a/src/static/js/pad.js b/src/static/js/pad.js index 32be03d6..8fcec23f 100644 --- a/src/static/js/pad.js +++ b/src/static/js/pad.js @@ -459,7 +459,7 @@ var pad = { // This will check if the prefs-cookie is set. // Otherwise it shows up a message to the user. padcookie.init(); - if (!readCookie("prefs")) + if (!padcookie.isCookiesEnabled()) { $('#loading').hide(); $('#noCookie').show(); diff --git a/src/static/js/pad_cookie.js b/src/static/js/pad_cookie.js index b563a7e6..62c88cff 100644 --- a/src/static/js/pad_cookie.js +++ b/src/static/js/pad_cookie.js @@ -23,6 +23,8 @@ var padcookie = (function() { + var cookieName = isHttpsScheme() ? "prefs" : "prefsHttp"; + function getRawCookie() { // returns null if can't get cookie text @@ -31,7 +33,7 @@ var padcookie = (function() return null; } // look for (start of string OR semicolon) followed by whitespace followed by prefs=(something); - var regexResult = document.cookie.match(/(?:^|;)\s*prefs=([^;]*)(?:;|$)/); + var regexResult = document.cookie.match(new RegExp("(?:^|;)\\s*" + cookieName + "=([^;]*)(?:;|$)")); if ((!regexResult) || (!regexResult[1])) { return null; @@ -44,7 +46,7 @@ var padcookie = (function() var expiresDate = new Date(); expiresDate.setFullYear(3000); var secure = isHttpsScheme() ? ";secure" : ""; - document.cookie = ('prefs=' + safeText + ';expires=' + expiresDate.toGMTString() + secure); + document.cookie = (cookieName + "=" + safeText + ";expires=" + expiresDate.toGMTString() + secure); } function parseCookie(text) @@ -122,6 +124,9 @@ var padcookie = (function() { return wasNoCookie; }, + isCookiesEnabled: function() { + return !!getRawCookie(); + }, getPref: function(prefName) { return cookieData[prefName]; |