Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/richdocuments.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@users.noreply.github.com>2021-04-14 14:39:25 +0300
committerGitHub <noreply@github.com>2021-04-14 14:39:25 +0300
commit49bba44319411f4e3cd85a275b8488cf98878132 (patch)
tree83165f212d6be1c2c0c9d8343f2b914e08ef3054
parent2c918dcfdc770fcd91fcd259882bfb7fdcf9f733 (diff)
parentb2f601169068e3dc5fff31ea20e7eeb4dd7d3ded (diff)
Merge pull request #1488 from nextcloud/bugfix/noid/cookie-parsing
Improve parsing of guest name cookie
-rw-r--r--src/helpers/guestName.js23
1 files changed, 11 insertions, 12 deletions
diff --git a/src/helpers/guestName.js b/src/helpers/guestName.js
index 2d508361..fec9b80a 100644
--- a/src/helpers/guestName.js
+++ b/src/helpers/guestName.js
@@ -26,18 +26,17 @@ import mobile from './mobile'
const getGuestNameCookie = function() {
const name = 'guestUser='
- const decodedCookie = decodeURIComponent(document.cookie)
- const cookieArr = decodedCookie.split(';')
- for (let i = 0; i < cookieArr.length; i++) {
- let c = cookieArr[i]
- while (c.charAt(0) === ' ') {
- c = c.substring(1)
- }
- if (c.indexOf(name) === 0) {
- return c.substring(name.length, c.length)
- }
- }
- return ''
+ const matchedCookie = document.cookie.split(';')
+ .map((cookie) => {
+ try {
+ return decodeURIComponent(cookie.trim())
+ } catch (e) {
+ return cookie.trim()
+ }
+ }).find((cookie) => {
+ return cookie.indexOf(name) === 0
+ })
+ return matchedCookie ? matchedCookie.substring(name.length) : ''
}
const setGuestNameCookie = function(username) {