You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
cookie to receive the login in the browser can not be read -> user is logged out after closing the browser #24438
If the username contains a space, the cookie which indicates that you are already logged in to this system can probably not be read or correctly assigned. This means that you will have to log in again and again as soon as the browser is closed.
This was tested on 3 NC instances by creating one user with and one without spaces. The one without spaces remained logged in, the one with had to log in again and again.
Basically PHP < 7.4.2 would encode Hans Peter as Hans+Peter and decode back to Hans Peter. However, PHP > 7.4.3 encode Hans Peter to Hans%20Peter and decode Hans+Peter to Hans+Peter leading to a clash in the expected UID.
php > echo(rawurldecode(urlencode('Hans Peter')));
Hans+Peter
php > echo(urldecode(rawurlencode('Hans Peter')));
Hans Peter
php > echo(urldecode(urlencode('Hans Peter')));
Hans Peter
php > echo(rawurldecode(rawurlencode('Hans Peter')));
Hans Peter
Activity
mziech commentedon Jan 6, 2021
I was observing the same behavior on my instance, essentially all users with a space in the name have to login twice after the session expired.
I tracked down the issue to a non-obvious change in PHP 7.4.2 and 7.4.3, which makes cookie encoding and decoding RFC compliant. See:
Basically PHP < 7.4.2 would encode
Hans PeterasHans+Peterand decode back toHans Peter. However, PHP > 7.4.3 encodeHans PetertoHans%20Peterand decodeHans+PetertoHans+Peterleading to a clash in the expected UID.Since NextCloud uses its own cookie encoding function, the PHP 7.4.3 encoding fix won't work. I fixed the issue by changing
urlencodetorawurlencodein https://github.com/nextcloud/server/blob/master/lib/private/Http/CookieHelper.php#L46Use RFC-compliant URL encoding for cookies
Use RFC-compliant URL encoding for cookies
Use RFC-compliant URL encoding for cookies
Use RFC-compliant URL encoding for cookies