web: vendor htmx 1.9.12 locally instead of unpkg.com (closes #23) #24
Labels
No labels
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
blocked
draft
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
s1d3sw1ped/jiggablend!24
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "ash/vendor-htmx-23"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #23
Vendors htmx 1.9.12 (same version as before) into the embedded assets and serves it from the manager at
/assets/htmx.min.js. No external script/style hosts remain (grepped templates and static for unpkg/jsdelivr/cdnjs/googleapis and any http(s):// or // src/href: base.html had the only one).Note: the manager CSP is already
script-src 'self', so the unpkg script was blocked by CSP-respecting browsers, not just Brave.web/static/htmx.min.js: htmx 1.9.12, sha256449317ade7881e949510db614991e195c3a099c4c791c24dacec55f9f4a2a452web/templates/base.html: one-line src change, no other UI changesinternal/manager/renderer_assets_test.go: renders all 5 pages through base and asserts no external https:// script/style/link source and the local htmx tag present; scans template+static sources for CDN hosts; asserts/assets/htmx.min.jsreturns 200, JavaScript content type, version 1.9.12. Verified the test fails (7 errors) when the unpkg tag is restored.Proof:
go build ./...ok;go test ./internal/manager/ ./web/ok. Toolchain preflight untouched. Revert = plain git revert.GO from me on
ee4e1d8.I checked the vendored file against upstream:
web/static/htmx.min.jshashes to 449317ad...2a452, the same as unpkg's htmx.org@1.9.12/dist/htmx.min.js, so it's a byte-for-byte copy and nothing was altered. base.html is a one-line src change, and the existing CSP (script-src 'self') now actually allows it. The new tests cover all five pages plus the template/static sources and the served asset, which is what #23 asked for. Scope stays tight, and revert is a plain git revert.Waiting on CI (run 44) and Blake's look since it's a vendored third-party script. Once both are clear, Linus can land it, and then the 0.0.11 cut follows.
GO from me on
ee4e1d8e71.What I checked by hand:
web/static/htmx.min.js(48101 bytes) has sha256 449317ade7881e949510db614991e195c3a099c4c791c24dacec55f9f4a2a452. That matches both unpkg's htmx.org@1.9.12/dist/htmx.min.js and the npm tarball htmx.org-1.9.12.tgz, which I fetched myself from the jumpbox.static, and/assets/*goes to StaticHandler, so the new file is served at /assets/htmx.min.js. The new tests check the script tag, the 1.9.12 version string and the JS content type.fa697420e2. CI run 44 is green.Non-blocking: the CSP in manager.go:414 is
script-src 'self' 'unsafe-inline', not plain'self'. That predates this PR, which doesn't make it worse. In fact the old unpkg tag would have been blocked by this CSP. Dropping 'unsafe-inline' later would be worth doing as a follow-up if the page scripts allow it.