Output encoding sandbox
One display name lands in page text, an attribute, an inline script, and a link. Pick the encoder each place needs and test it with probe values.
What you’re looking at
One display name lands in page text, an attribute, an inline script, and a link. Pick the encoder each place needs and test it with probe values.
Your goal: Pick the right encoder for each place a name appears, so no value breaks out and every value displays as typed.
- Probe value
- the buttons at the top. Each is a test name with tricky characters. The note says what it tests.
- Places
- four panels: Page text, Quoted attribute, Inline script string, and Link target. Each has an Encoder menu.
- Result
- the markup each panel produces, and a line saying whether the value stays in its slot and displays as typed.
- Walkthrough
- the numbered path beside the workbench (below it on a phone). Each step says what to do and what you should see. Hints open one at a time.
Words you will meet
- HTML
- the language web pages are written in
- URL
- web address
Start with step 1 in the walkthrough. Every step says what to do and what you should see. The whole thing takes about 2 min to talk through.
Briefing
A profile page writes the user’s display name and website into four places: page text, a form attribute, a greeting in an inline script, and a link.
Pick an encoder for each place and test it with the probe values. A slot passes when no probe can leave it and every probe still displays exactly as the user typed it. The markup is shown as text and never rendered.
<p class="bio">Tom <3 Jerry & <b>friends</b></p>
The value leaves its slot. The parser now reads part of it as markup or code.
<input name="display" value="Tom <3 Jerry & <b>friends</b>">
The value stays in its slot and displays as typed.
<script>const greeting = 'Hello, Tom <3 Jerry & <b>friends</b>';</script>
The value stays in its slot but displays as: Tom <3 Jerry & <b>friends</b>
<a href="Tom <3 Jerry & <b>friends</b>">Website</a>
The value stays in its slot and displays as typed.
4 of 4 places still fail a probe.
The whole walkthrough
Every step in order, written to be read aloud: 295 words, about 2 min. It gives away every answer, so try the steps first.