Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Login with Safari: Error updating user language #14793

Closed
1 task done
louis77 opened this issue Feb 25, 2021 · 5 comments · Fixed by #15452
Closed
1 task done

Login with Safari: Error updating user language #14793

louis77 opened this issue Feb 25, 2021 · 5 comments · Fixed by #15452
Labels
good first issue Likely to be an easy fix type/bug
Milestone

Comments

@louis77
Copy link

louis77 commented 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.

@lunny
Copy link
Member

lunny commented Feb 25, 2021

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

@louis77
Copy link
Author

louis77 commented Feb 25, 2021

I found this issue in the golang repo:
golang/go#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]

@noerw noerw added type/upstream This is an issue in one of Gitea's dependencies and should be reported there type/bug labels Feb 28, 2021
@zeripath zeripath added good first issue Likely to be an easy fix and removed type/upstream This is an issue in one of Gitea's dependencies and should be reported there labels Mar 3, 2021
@zeripath zeripath added this to the 1.14.0 milestone Mar 3, 2021
@zeripath
Copy link
Contributor

zeripath commented 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

@lunny
Copy link
Member

lunny commented Apr 13, 2021

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

@louis77
Copy link
Author

louis77 commented Apr 14, 2021

I can confirm, works well for me now.

zeripath pushed a commit that referenced this issue Apr 14, 2021
Fix #14793.

The previous implementation used the first return value of matcher.Match, which is the chosen language tag but may contain extensions such as de-DE-u-rg-chzzzz.

As mentioned in the documentation of language package, matcher.Match also returns the index of the supported tags, so I think it is better to use it rather than manipulate the returned language tag.
zeripath pushed a commit to zeripath/gitea that referenced this issue Apr 15, 2021
Backport go-gitea#15452

Fix go-gitea#14793.

The previous implementation used the first return value of matcher.Match, which is the chosen language tag but may contain extensions such as de-DE-u-rg-chzzzz.

As mentioned in the documentation of language package, matcher.Match also returns the index of the supported tags, so I think it is better to use it rather than manipulate the returned language tag.
6543 pushed a commit that referenced this issue Apr 15, 2021
Backport #15452

Fix #14793.

The previous implementation used the first return value of matcher.Match, which is the chosen language tag but may contain extensions such as de-DE-u-rg-chzzzz.

As mentioned in the documentation of language package, matcher.Match also returns the index of the supported tags, so I think it is better to use it rather than manipulate the returned language tag.

Co-authored-by: Naohisa Murakami <[email protected]>
@go-gitea go-gitea locked and limited conversation to collaborators Jun 4, 2021
AbdulrhmnGhanem pushed a commit to kitspace/gitea that referenced this issue Aug 10, 2021
Fix go-gitea#14793.

The previous implementation used the first return value of matcher.Match, which is the chosen language tag but may contain extensions such as de-DE-u-rg-chzzzz.

As mentioned in the documentation of language package, matcher.Match also returns the index of the supported tags, so I think it is better to use it rather than manipulate the returned language tag.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
good first issue Likely to be an easy fix type/bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants