vole
Site
Clone
Read only, no credentials:
https://rodent.software/vole.git
Write over SSH with a registered key:
git clone ssh://git@rodent.software/vole.git
Self-hosted forge that lives in your Git repo.
Load the Prism worker from the static route
9a9e708c1def7250086e612cdee88e1ea12298ab · Keenan Nemetz · 21d ago · parent 7c02af12
Load the Prism worker from the static route The highlighting script asked for /static/prism-worker.js, but every browser asset is served under /-/static/. The request fell through to the HTML 404 page, so the browser refused the worker for its MIME type and every blob stayed plain. HTMX also compiles an hx-trigger filter with Function(), which script-src 'self' blocks. The two polling triggers used a visibility filter for that; drop the filter, pause the request in app.js while the tab is hidden, and turn eval off in the HTMX config so a future filter is caught instead of failing in production. Tests hold the worker to its route and the templates to trigger forms that do not need eval.
server/ui_test.go +25−2
| @@ -366,8 +366,9 @@ func TestHTMXDoesNotInjectInlineStyles(t *testing.T) { | |||
| 366 | 366 | t.Fatalf("landing page = %d", code) | |
| 367 | 367 | } | |
| 368 | 368 | if !strings.Contains(shell, `name="htmx-config"`) || | |
| 369 | !strings.Contains(shell, `"includeIndicatorStyles":false`) { | ||
| 370 | t.Fatal("the shell does not turn off HTMX's inline indicator styles") | ||
| 369 | !strings.Contains(shell, `"includeIndicatorStyles":false`) || | ||
| 370 | !strings.Contains(shell, `"allowEval":false`) { | ||
| 371 | t.Fatal("the shell does not turn off HTMX's inline indicator styles or eval") | ||
| 371 | 372 | } | |
| 372 | 373 | code, css := f.get("/-/static/vole.css") | |
| 373 | 374 | if code != 200 { | |
| @@ -925,6 +926,28 @@ func TestActivityFeedIncludesIssuesAndFilters(t *testing.T) { | |||
| 925 | 926 | } | |
| 926 | 927 | } | |
| 927 | 928 | ||
| 929 | // The syntax highlighter is a worker, and a browser will not start one served | ||
| 930 | // as HTML. A wrong URL falls through to the catch-all's 404 page, so this holds | ||
| 931 | // the worker and the route to the same path under /-/static/. | ||
| 932 | func TestPrismWorkerIsAServedStaticAsset(t *testing.T) { | ||
| 933 | t.Parallel() | ||
| 934 | f := newFixture(t) | ||
| 935 | resp, err := http.Get(f.http.URL + "/-/static/prism-worker.js") | ||
| 936 | if err != nil { | ||
| 937 | t.Fatal(err) | ||
| 938 | } | ||
| 939 | defer resp.Body.Close() | ||
| 940 | if resp.StatusCode != http.StatusOK { | ||
| 941 | t.Fatalf("/-/static/prism-worker.js = %d", resp.StatusCode) | ||
| 942 | } | ||
| 943 | if ct := resp.Header.Get("Content-Type"); !strings.Contains(ct, "javascript") { | ||
| 944 | t.Fatalf("prism-worker.js Content-Type = %q, want JavaScript", ct) | ||
| 945 | } | ||
| 946 | if code, _ := f.get("/static/prism-worker.js"); code != http.StatusNotFound { | ||
| 947 | t.Fatalf("/static/prism-worker.js = %d, want the 404 the worker URL must not use", code) | ||
| 948 | } | ||
| 949 | } | ||
| 950 | |||
| 928 | 951 | // Every script is a static asset: the page references it under /-/static/ and | |
| 929 | 952 | // nothing is inlined into a template, so the CSP stays script-src 'self' and the | |
| 930 | 953 | // script is editable as JavaScript rather than as a Go string. The passkey | |