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

[rhel-9.3] backport fixes #19740

Merged
merged 7 commits into from
Dec 12, 2023
Merged

Conversation

martinpitt
Copy link
Member

jelly and others added 7 commits December 12, 2023 14:17
Split the po files into po.$lang.js and po.manifest.$lang.js so the
shell can only serve the translated manifests for the C bridge we now
need to also load globbed manifest translations. The Python bridge does
not support globbing so we need to explicitly load the po.js file as
well.

Closes cockpit-project#18224

Co-authored-by: Allison Karlitskaya <allison.karlitskaya@redhat.com>

This is intrusive for rhel-9.3 branch, but field-tested by now, and
allows us to cleanly backport other important fixes. Cherry-picked from
89781ba
Make several fixes to our handling of the `Accept-Language:` header:

 - we used to crash if `q=` contained invalid values due to an unchecked
   cast with `float()`.  Catch that error and ignore the entry in that
   case.

 - our handling of English was incorrect.  We would look for and fail to
   find po.en.js, and move on to the next item in the list.  That means
   if the user listed English first, followed by another language which
   we did support, they'd see Cockpit in that other language, which is
   unexpected.  This is a regression introduced by f4be906.  Now we
   drop all items that sort after English.

 - our handling of fallbacks (ie: 'de' from 'de-de') was incorrect.
   RFC4647 §3.4 says that a "Lookup" should consider items in the order
   they're found, stripping each item down to its base form, before
   considering the next item.  This passes a gut check, as well: a user
   who lists `de-de, nl` probably expects to see a German translation
   before a Dutch one.

We also now mark the parser code as `@lru_cache`.  This makes sense:
within a given run of cockpit-bridge, we're likely to see very many
copies of the Accept-Language header, and they're practically always
going to be identical.  Make sure we now accept and return immutable
types to prevent weird side-effects.  We also take the time to remove
duplicate items from the list.

While we're at it, up our testing game a bit to make sure we don't
mistreat requests for 'English' in the future.

Closes cockpit-project#19526

Cherry-picked from b6564b2 as a prerequisite for cleanly
cheryy-picking important fixes.
We removed support for `.min.` filenames because we thought that nobody
was using it anymore, but there are still external packages that make
use of it.

Add it back again, but only for the case where the non-minified version
isn't present.  The minified version can always be explicitly requested
via its full filename (minus `.gz`, if applicable).

Add a bit of debugging output and some test cases to make sure we handle
the combinations properly.

Fixes https://issues.redhat.com/browse/RHEL-19005

Cherry-picked from 5d00faa
This call was introduced in commit 483027a, but this API only exists
since glib 2.72, while current RHEL 9.3 still has
2.68. This causes client to crash with an AttributeError.

Provide a fallback implementation.

https://issues.redhat.com/browse/RHEL-18989

Cherry-picked from 82c59a0
With only looking at aos-release's `ID` field, we are missing out a lot
of derivatives, such as CentOS Stream, Rocky, or Debian-likes. Consider
ID_LIKE as well to fix that.

E.g. on Ubuntu, `ID_LIKE` is "debian", on CentOS it's "rhel fedora", on
Rocky Linux it's "rhel centos fedora".

Use that to clean up the manifest map, as Ubuntu and RHEL are now
redundant.

testBasic covers the "direct package name" case in the manifest. Add
a new testOsMap test to check the distroname → packagename map that we
use in real life.

Cherry-picked from 7bbf916
Commit 7bbf916 introduced a major bug: If the OS in os-release was
not found in the iteration, get_config() would return the whole map
instead of the default value. That crashed the page with
`TypeError: names.forEach is not a function`.

This is awkward to do correctly with .find(), especially due to
modifying `val` as a side effect; iterate over `os_list` the good old
`for` way instead.

This was hidden by the test's manifest override leaving
`appstream_config_packages` intact, so it was always taken from the real
underlying OS. Override it as well.

Cherry-picked from 0eeb475
@martinpitt martinpitt added the backport apply a commit from master to a stable branch label Dec 12, 2023
@martinpitt martinpitt merged commit 957283a into cockpit-project:rhel-9.3 Dec 12, 2023
23 checks passed
@martinpitt martinpitt deleted the r93-fixes branch December 12, 2023 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport apply a commit from master to a stable branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants