E107
Error
Syntax and structure
E107 — A URL a browser would run
javascript:, data:, vbscript:, blob: and file: URLs run or load something the page did not write. A link takes http, https, mailto, tel, sms, ftp or a relative URL. In head { }, a script(src:) or a refresh whose address a value chooses is refused the same way.
What the compiler said
error[E107]: `to` on Link names the `javascript` scheme, which a browser runs --> src/App.wf:3:16 | 3 | Link("Go", to: "javascript:alert(1)") | ^^ = help: A URL here may be relative, or name http, https, mailto, tel, sms or ftp = docs: https://webfluent.monzeromer.dev/errors/E107
The fix
Broken
page P(path: "/", title: "T", description: "D") {
Heading("Go").h1
Link("Go", to: "javascript:alert(1)")
}
Fixed
page P(path: "/", title: "T", description: "D") {
Heading("Go").h1
Link("Go", to: "https://example.com/")
}
A relative URL, or http, https, mailto, tel, sms,
ftp.
A page's head { } is held to the same rule, and more: a
script(src:) must be written out, since whoever controls a value it
reads would choose the script the page runs; a meta(http-equiv:
"refresh") whose address comes from a value is an open redirect, and
an http-equiv a value chooses could become one.
page P(path: "/", title: "T", description: "D") {
head { script(src: query.lib) }
Heading("Home").h1
}
error[E107]: `head { script(src: …) }` loads a script a value chooses: whoever controls the value runs code as this site
--> src/App.wf:2:12
|
2 | head { script(src: query.lib) }
| ^^^^^^
= help: Write the address out — `script(src: "/analytics.js")` — and keep what varies in the script's own data
= docs: https://webfluent.monzeromer.dev/errors/E107
Fix: head { script(src: "/analytics.js") }; send a reader on with
navigate(…), which keeps to the site's routes.
Each example is a whole program: it is all of src/App.wf in a project with no other .wf file (trying an example).
lints cannot lower it: it would ship a broken page.