Skip to content

Show a page's source with view-source: - #18

Closed
pathscale wants to merge 2 commits into
feat/wasm-script-tagfrom
feat/view-source
Closed

pathscale wants to merge 2 commits into
feat/wasm-script-tagfrom
feat/view-source

Conversation

@pathscale

Copy link
Copy Markdown
Owner

Stacked on #17.

view-source:https://example.com fetches what it names and shows the bytes
instead of rendering them.

No new URL parsing

view-source:https://x already parses as a URL whose scheme is view-source
and whose path is the inner address. So request_from_input accepts it
unchanged, the address bar shows it, and history holds it like any other entry.

Opening it in a new tab is the existing open_tab command with that
address — nothing here needs to know whether it landed in a new tab or the
current one, which is why no new plumbing was needed for that.

Escaped into a <pre>, and nothing else

Nothing may reformat, pretty-print or re-serialise. A source view that showed a
parsed and re-emitted tree would be answering a different question, and for a
page whose claim is there is no script here it would be the wrong answer: the
reader is checking the bytes, not the tree.

The test pins three properties:

  • the script tag survives with its type readable
  • markup is escaped rather than interpolated
  • ampersands are escaped before angle brackets — the other order turns
    &lt; into &amp;lt; and quietly corrupts every escape on the page

Verified

Ran against the live site in the window:
chuzz-gui "view-source:https://vliw-12345.xyz/" fetches and renders with no
error, window healthy at 197 MB RSS.

25 tests, clippy clean, fmt clean.

--capture cannot verify this, the same gap #17 notes: it loads through
document_loader, which fetches directly, so view-source: reaches reqwest as
a bad scheme. Both that and the wasm-tag path would be covered by teaching the
capture loader the same routing.

meh added 2 commits August 15, 2026 21:08
`view-source:https://example.com` fetches what it names and shows the
bytes instead of rendering them.

No new URL parsing. `view-source:https://x` already parses as a URL whose
scheme is `view-source` and whose path is the inner address, so
`request_from_input` accepts it, the address bar shows it, and history
holds it like any other entry. Opening it in a new tab is the existing
`open_tab` command with that address; nothing here needs to know whether
it is a new tab or the current one.

The source is escaped and put in a `<pre>`, and that is the whole job.
Nothing may reformat, pretty-print or re-serialise it: a source view that
showed a parsed and re-emitted tree would be answering a different
question. For a page whose claim is "there is no script here" it would be
the wrong answer, because the reader is checking the bytes rather than
the tree.

The test pins the properties that matter: the script tag survives with
its type readable, markup is escaped rather than interpolated, and
ampersands are escaped before angle brackets -- the other order turns
`&lt;` into `&amp;lt;` and quietly corrupts every escape on the page.
The scheme existed and the only way to reach it was to type it. Cmd-U is
what Chrome and Safari bind, and it opens a new tab rather than replacing
the page, so the source and the page it came from stay side by side.

Inert on a tab that is already showing source: the naive version opens
view-source:view-source:https://..., which the address bar accepts and
nothing can render.
@pathscale

Copy link
Copy Markdown
Owner Author

Folded into #19, which now carries this whole stack against master.

@pathscale pathscale closed this Aug 16, 2026
@pathscale
pathscale deleted the feat/view-source branch August 25, 2026 18:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant