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

Check if applied locale correctly lowers chars and fallback #19905

Closed
wants to merge 3 commits into from

Conversation

basilgello
Copy link
Collaborator

.. to default region if it does not.

Fixes #19883.

@basilgello
Copy link
Collaborator Author

Got an ACK from @hbayindir in the Debian bug report thread:

Thanks a lot for your intense effort. The new version you uploaded is working 
as intended without any changes to locale.

I can confirm that the problem is now solved.

Let's start the review?

@basilgello
Copy link
Collaborator Author

@fuzzard @lrusak @Rechi @phunkyfish @DaveTBlake Sorry I dont see who is actually code owner of LangInfo.cpp - it was written so long ago… :)

@phunkyfish phunkyfish added Type: Fix non-breaking change which fixes an issue v20 Nexus labels Jun 29, 2021
@phunkyfish phunkyfish added this to the N* 20.0 Alpha 1 milestone Jun 29, 2021
xbmc/LangInfo.cpp Outdated Show resolved Hide resolved
xbmc/LangInfo.cpp Outdated Show resolved Hide resolved
xbmc/LangInfo.cpp Outdated Show resolved Hide resolved
@basilgello
Copy link
Collaborator Author

@lrusak Fixed, thanks! Not sure if m_defaultRegion.m_strName is meaningful though, but at least the failing region name should be displayed correctly and the latter messages from SetGlobalLocale show the locale is set to C

@basilgello
Copy link
Collaborator Author

Not sure if m_defaultRegion.m_strName is meaningful though

Yes, default region is marked as 'N/A' but the locale info is displayed as INFO:

2021-06-30 05:11:15.500 T:8514     INFO <general>: CAddonMgr::FindAddon: resource.language.tr_tr v9.0.22 installed
2021-06-30 05:11:15.551 T:8514     INFO <general>: CLangInfo: loading resource.language.tr_tr language information...
2021-06-30 05:11:15.552 T:8514     INFO <general>: global locale set to tr_TR.UTF-8
2021-06-30 05:11:15.552 T:8514    ERROR <general>: region 'Türkiye' is affected by #19883 - falling back to default region 'N/A'
2021-06-30 05:11:15.552 T:8514     INFO <general>: global locale set to C
2021-06-30 05:11:15.552 T:8514     INFO <general>: CLangInfo: loading resource.language.tr_tr language strings...
2021-06-30 05:11:15.597 T:8514     INFO <general>: global locale set to tr_TR.UTF-8
2021-06-30 05:11:15.597 T:8514    ERROR <general>: region 'Türkiye' is affected by #19883 - falling back to default region 'N/A'
2021-06-30 05:11:15.597 T:8514     INFO <general>: global locale set to C

I think there's no need to move ifdeffery from https://github.com/xbmc/xbmc/blob/master/xbmc/LangInfo.cpp#L222 into a separate function std::string CLangInfo::GetLocaleName(CLangInfo::CRegion& region); just to print exact locale names?

@lrusak
Copy link
Contributor

lrusak commented Jun 30, 2021

I think it's fine as is. The only other thing I can say is maybe change to LOGWARNING rather than LOGERROR but I'm fine either way.

@phunkyfish
Copy link
Contributor

jenkins build this please

Copy link
Contributor

@howie-f howie-f left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i did not see this bug on windows 10 with turkish language (system and kodi) installed.
unfortunately can't test android and osx... android would be interesting though

tools/Linux/kodi.sh.in Outdated Show resolved Hide resolved
xbmc/LangInfo.cpp Outdated Show resolved Hide resolved
@basilgello
Copy link
Collaborator Author

android would be interesting though

I just tested 19.1 from F-Droid in my LineageOS tablet and it seems Android is not vulnerable due to https://github.com/xbmc/xbmc/blob/19.1-Matrix/xbmc/LangInfo.cpp#L297

In fact, C.UTF-8 becomes the default region applied by this fix if Turkish I is detected.

do we need to unset those in further files - example https://github.com/xbmc/xbmc/blob/master/tools/Linux/kodi-standalone.sh.in ? and what are consequences of unsetting as LC_ALL

No, we need to unset LC_* variables only once, just before kodi.bin is invoked. Unsetting and setting back LC_ALL in X11 code alters the already-unset value so it should not interfere. The proper way avoiding kodi.sh.in edit is to understand what Kodi dependency breaks rendering before GetLocaleName is first invoked, but I did not manage to dig that out.

@basilgello
Copy link
Collaborator Author

@phunkyfish can you please run unpatched 19.1 on OSX with Turkish system and Kodi language and check whether the bug manifests?

@phunkyfish
Copy link
Contributor

phunkyfish commented Aug 28, 2021

@phunkyfish can you please run unpatched 19.1 on OSX with Turkish system and Kodi language and check whether the bug manifests?

How exactly do I do that? Being a native English speaker I never deal with other languages!!!

@basilgello
Copy link
Collaborator Author

basilgello commented Aug 28, 2021 via email

@phunkyfish
Copy link
Contributor

How will I know if they are readable? If there is a screenshot of what they should look like?

@basilgello
Copy link
Collaborator Author

basilgello commented Aug 28, 2021

Screenshots of affected Kodi are in #19883. Settings pane has buttons with captions and images if not affected but is empty if it is.

@fuzzard
Copy link
Contributor

fuzzard commented Sep 12, 2021

Screen Shot 2021-09-13 at 9 14 51 am

Appears to be ok (if ive done what you have said properly. Was just a stock 19.1 release build, MacOS 11.5.2

@basilgello
Copy link
Collaborator Author

basilgello commented Sep 13, 2021 via email

@howie-f
Copy link
Contributor

howie-f commented Sep 14, 2021

should be ready after it got a bit love and polishing 😉
EDIT: please also fix the warning message (nobody will know what issue 19883 was back then)

@basilgello
Copy link
Collaborator Author

Yeah, I paused this after I tried to move kodi.sh.in part into xbmc/platform/posix/main.cpp and the fix failed to address an issue :) Gonna try it out once more & fix the rest + backport!

.. to default region if it does not.

Fixes xbmc#19883.

Signed-off-by: Vasyl Gello <vasek.gello@gmail.com>
Signed-off-by: Vasyl Gello <vasek.gello@gmail.com>
@basilgello
Copy link
Collaborator Author

@howie-f I fixed the points you brought on the last review! Unfortunately I could not get rid of un-setting environment variables in kodi.sh.in because something does not honor even the thermonuclear locale setting:

   std::setlocale(LC_ALL, "C");
   std::locale::global(std::locale("C"));

I think we should go with battle-tested code here, and the fact that kodi.sh.in is used only by Linux platform suggest it is a correct place to alter LC_* stuff.

Signed-off-by: Vasyl Gello <vasek.gello@gmail.com>
@ksooo
Copy link
Member

ksooo commented Sep 26, 2021

Sorry, I don't want to be PITA, but shouldn't we try to find and fix the root cause of this problem instead of polluting Kodi code base with workarounds?

@basilgello
Copy link
Collaborator Author

Sorry, I don't want to be PITA, but shouldn't we try to find and fix the root cause of this problem instead of polluting Kodi code base with workarounds?

One of root cases of this problem is that https://github.com/xbmc/xbmc/blob/19.1-Matrix/xbmc/filesystem/SpecialProtocol.cpp#L207 uses lower/upper functions to find files in a case-insensitive manner. There are others + some that even I failed to figure out by today :(

I am OK to solve that issue completely, but I am really afraid (see my comments in 19883) that the 'true' fix will be greater than CDateTime one :(

@ksooo
Copy link
Member

ksooo commented Sep 26, 2021

but I am really afraid (see my comments in 19883) that the 'true' fix will be greater than CDateTime one :(

Let's do the job right and bite that bullet.

Kodi "survived" without this fix for many many years. I don't see the need for this kinda special case to hurry and go with a workaround.

@basilgello
Copy link
Collaborator Author

Kodi "survived" without this fix for many many years. I don't see the need for this kinda special case to hurry and go with a workaround.

Matrix users from Turkey already reported this on r/kodi and in Debian. I am OK to hold this for Nexus, but Matrix should be worked around. I do ship the fix already in Debian, but Manjaro / Arch / Gentoo users still lack it. Should we leave it as-is in such case?

Copy link
Member

@ksooo ksooo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I don't see this in master. This is only a workaround and we know that the root cause is in Kodi code base. So, let's fix it properly.

@ksooo
Copy link
Member

ksooo commented Sep 26, 2021

Matrix users from Turkey already reported this on r/kodi and in Debian. I am OK to hold this for Nexus, but Matrix should be worked around.

I do agree.

@jenkins4kodi
Copy link
Contributor

I've made some formatting changes to meet the current code style. The diffs are available in the following links:

For more information please see our current code style guidelines.

@basilgello basilgello added WIP PR that is still being worked on and removed Backport: Done labels Sep 26, 2021
Grabber66 pushed a commit to Grabber66/context.downloadit that referenced this pull request Apr 27, 2022
… Kodi workaround

Kodi unsets LC_CTYPE since xbmc/xbmc#19905 was merged,
so DownloadIt errored if the title contained non-ASCII characters.
@fuzzard fuzzard removed this from the Nexus 20.0 Beta 1 milestone Oct 1, 2022
@fuzzard fuzzard removed the v20 Nexus label Oct 1, 2022
@basilgello basilgello closed this Jan 21, 2023
@basilgello basilgello deleted the workaround-19883 branch January 21, 2023 10:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Fix non-breaking change which fixes an issue WIP PR that is still being worked on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Turkish locale set via LANG / LC_CTYPE / LC_ALL or by SetGlobalLocale breaks skin loading on any Linux
9 participants