Login with Safari: Error updating user language #6922

Closed
opened 2025-11-02 07:11:10 -06:00 by GiteaMirror · 5 comments
Owner

Originally created by @louis77 on GitHub (Feb 25, 2021).

This is a follow-up to issue #9806 which is closed and unfortunately not available for reopening.

Logging in with Safari Version 14.0.3 (16610.4.3.1.4) causes the following error message:

routers/user/auth.go:524:[handleSignInFull()] Error updating user language [user: 3, locale: de-DE-u-rg-chzzzz]

and shows an empty page. Obviously Safari is sending a strange locale.

Checking with whatismyip.org:

HTTP_HOST: www.whatsmyip.org
HTTP_ACCEPT: text/html, application/xhtml+xml, application/xml;q=0.9, */*;q=0.8
HTTP_ACCEPT_LANGUAGE: de-ch
HTTP_CONNECTION: keep-alive
HTTP_ACCEPT_ENCODING: gzip, deflate, br
HTTP_USER_AGENT: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.3 Safari/605.1.15

Gitea version: 1.13.2 built with GNU Make 4.2.1, go1.14.6 : bindata
Running gitea binary compiled from source with no reverse proxies on port 443
OS: Linux 4.19.0-13-cloud-amd64 #1 SMP Debian 4.19.160-2 (2020-11-28) x86_64 GNU/Linux
DB: PostgreSQL 12

Feb 24 22:18:13 runner gitea[8819]: [Macaron] 2021-02-24 22:18:13: Started POST /user/login for 77.58.0.94
Feb 24 22:18:13 runner gitea[8819]: [Macaron] 2021-02-24 22:18:13: Completed POST /user/login 0  in 149.066657ms
Feb 24 22:18:13 runner gitea[8819]: #033[36m2021/02/24 22:18:13 #033[0m#033[32mrouters/user/auth.go:524:#033[32mhandleSignInFull()#033[0m #033[1;31m[E]#033[0m Error updating user language [user: 1, locale: de-DE-u-rg-chzzzz]
F

I've changed the language column in the user table:

ALTER TABLE "public"."user" ALTER COLUMN "language" SET DATA TYPE varchar(20);

then the error goes away. So either the locale must be stripped or the column length must be made greater than 5.

Originally created by @louis77 on GitHub (Feb 25, 2021). This is a follow-up to issue #9806 which is closed and unfortunately not available for reopening. Logging in with Safari `Version 14.0.3 (16610.4.3.1.4)` causes the following error message: `routers/user/auth.go:524:[handleSignInFull()] Error updating user language [user: 3, locale: de-DE-u-rg-chzzzz]` and shows an empty page. Obviously Safari is sending a strange locale. Checking with whatismyip.org: ``` HTTP_HOST: www.whatsmyip.org HTTP_ACCEPT: text/html, application/xhtml+xml, application/xml;q=0.9, */*;q=0.8 HTTP_ACCEPT_LANGUAGE: de-ch HTTP_CONNECTION: keep-alive HTTP_ACCEPT_ENCODING: gzip, deflate, br HTTP_USER_AGENT: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.3 Safari/605.1.15 ``` Gitea version: `1.13.2 built with GNU Make 4.2.1, go1.14.6 : bindata` Running gitea binary compiled from source with no reverse proxies on port 443 OS: `Linux 4.19.0-13-cloud-amd64 #1 SMP Debian 4.19.160-2 (2020-11-28) x86_64 GNU/Linux` DB: PostgreSQL 12 - Can you reproduce the bug at https://try.gitea.io: - [X] No - Log gist: ``` Feb 24 22:18:13 runner gitea[8819]: [Macaron] 2021-02-24 22:18:13: Started POST /user/login for 77.58.0.94 Feb 24 22:18:13 runner gitea[8819]: [Macaron] 2021-02-24 22:18:13: Completed POST /user/login 0 in 149.066657ms Feb 24 22:18:13 runner gitea[8819]: #033[36m2021/02/24 22:18:13 #033[0m#033[32mrouters/user/auth.go:524:#033[32mhandleSignInFull()#033[0m #033[1;31m[E]#033[0m Error updating user language [user: 1, locale: de-DE-u-rg-chzzzz] F ``` I've changed the `language` column in the `user` table: ```sql ALTER TABLE "public"."user" ALTER COLUMN "language" SET DATA TYPE varchar(20); ``` then the error goes away. So either the locale must be stripped or the column length must be made greater than 5.
GiteaMirror added the good first issuetype/bug labels 2025-11-02 07:11:10 -06:00
Author
Owner

@lunny commented on GitHub (Feb 25, 2021):

So strip de-DE-u-rg-chzzzz to de-DE is acceptable?

@lunny commented on GitHub (Feb 25, 2021): So strip `de-DE-u-rg-chzzzz` to `de-DE` is acceptable?
Author
Owner

@louis77 commented on GitHub (Feb 25, 2021):

I found this issue in the golang repo:
https://github.com/golang/go/issues/24211

Seems to be a bug in a Go lib. The most recent "solution" for this is:

langTag, _, _ := languageMatcher.Match(tags...)
langTagString := langTag.String()[0:2]
@louis77 commented on GitHub (Feb 25, 2021): I found this issue in the golang repo: https://github.com/golang/go/issues/24211 Seems to be a bug in a Go lib. The most recent "solution" for this is: ```go langTag, _, _ := languageMatcher.Match(tags...) langTagString := langTag.String()[0:2] ```
Author
Owner

@zeripath commented on GitHub (Mar 3, 2021):

So strip de-DE-u-rg-chzzzz to de-DE is acceptable?

What we should do is strip off the - one by one until there is a locale available that matches

@zeripath commented on GitHub (Mar 3, 2021): > So strip `de-DE-u-rg-chzzzz` to `de-DE` is acceptable? What we should do is strip off the - one by one until there is a locale available that matches
Author
Owner

@lunny commented on GitHub (Apr 13, 2021):

@louis77 could you help to confirm #15452 fix this?

@lunny commented on GitHub (Apr 13, 2021): @louis77 could you help to confirm #15452 fix this?
Author
Owner

@louis77 commented on GitHub (Apr 14, 2021):

I can confirm, works well for me now.

@louis77 commented on GitHub (Apr 14, 2021): I can confirm, works well for me now.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#6922