-
Bug
-
Resolution: Done-Errata
-
Undefined
-
rhel-9.3.0
-
None
-
cockpit-307-1.el9
-
Yes
-
Important
-
ZStream, Regression
-
rhel-sst-cockpit
-
ssg_front_door
-
None
-
False
-
-
None
-
Red Hat Enterprise Linux
-
None
-
Approved Blocker
-
Pass
-
None
-
None
What were you trying to do that didn't work?
There was a apparently a re-implementation of cockpit-bridge between 286.2-1.el9_2 and 300.1-1.el9_3: the new implementation is now in Python instead of C.
This re-implementation broke the support of "minified" files:
with older release, "foo.min.js.gz" or "foo.min.js" was served when cockpit UI was requesting "foo.js".
It's not the case anymore because the code in /usr/lib/python3.9/site-packages/cockpit/packages.py doesn't implement this mapping:
143 class Package: 144 PO_JS_RE: ClassVar[Pattern] = re.compile(r'po\.([^.]+)\.js(\.gz)?') : 162 def ensure_scanned(self) -> None: : 180 po_match = Package.PO_JS_RE.fullmatch(name) 181 if po_match: 182 locale = po_match.group(1) 183 # Accept-Language is case-insensitive and uses '-' to separate variants 184 lower_locale = locale.lower().replace('_', '-') 185 self.translations[lower_locale] = name 186 else: 187 basename = name[:-3] if name.endswith('.gz') else name 188 self.files[basename] = name :
Here above on line 187 there is support for ".gz" but not ".min" sub-extension.
Digging into this, I'm proposing the attached generic code ("cockpit_packages.py"), handling both ".gz" and ".min" sub-extension more wisely.
Note that it's not sufficient to just strip ".min" to get the base name, because potentially the cockpit UI can reference different names, for example:
- "foo.js" requested by cockpit UI should be served as "foo.js.gz", but also "foo.min.js.gz" or "foo.min.js" if any of those exist
- "foo.min.js" requested by cockpit UI should be served as "foo.min.js.gz" if file exists, or "foo.min.js" otherwise
If just stripping ".min" from the file name, then requesting "foo.min.js" would fail.
See also section Reproducer for ".min" as requested file for additional details.
Please provide the package NVR for which bug is seen:
cockpit-300.1-1.el9_3.x86_64
How reproducible:
Always
Steps to reproduce
- Create a custom plugin based on "pinger" (https://raw.githubusercontent.com/cockpit-project/cockpit/master/examples/pinger/pinger.js)
# mkdir -p /usr/local/share/cockpit/pinger # cd /usr/local/share/cockpit/pinger # curl -O https://raw.githubusercontent.com/cockpit-project/cockpit/master/examples/pinger/manifest.json # curl -O https://raw.githubusercontent.com/cockpit-project/cockpit/master/examples/pinger/ping.html # curl -O https://raw.githubusercontent.com/cockpit-project/cockpit/master/examples/pinger/pinger.js
- Compress "pinger.js" into "pinger.js.gz" then rename it to "pinger.min.js.gz"
# gzip pinger.js # mv pinger.js.gz pinger.min.js.gz
- Restart cockpit.service
Expected results
"pinger.js" requested by cockpit UI loads
Actual results
"pinger.js" fails to load
Reproducer for ".min" as requested file
- Create a custom module that will hold more custom files
# mkdir -p /usr/local/share/cockpit/custom # cd /usr/local/share/cockpit/custom # cat > /usr/local/share/cockpit/custom/manifest.json << EOF { "version": "1", "version-note": "custom test" } EOF
- Upload some javascript there, intentionally named with ".min" inside
# curl -O https://code.jquery.com/jquery-3.7.1.min.js
- Edit /usr/local/share/cockpit/ping/ping.html to reference the file (line 7)
# vim /usr/local/share/cockpit/ping/ping.html [...] 3 <head> 4 <title>Pinger</title> 5 <meta charset="utf-8"> 6 <script src="../base1/cockpit.js"></script> 7 <script src="../custom/jquery-3.7.1.min.js"></script> 8 </head> [...]
- Restart cockpit.service
Expected results
"jquery-3.7.1.min.js" requested by "ping.html" loads
Actual results
"jquery-3.7.1.min.js" fails to load
- links to
-
RHBA-2023:120853 cockpit bug fix and enhancement update