Commit 1dde156
Make the web page's argv string encoding a faithful round trip
Fixes scrutineer finding #2519.
In fiat-html/main.js, splitUnescapedSpaces and joinWithEscaping convert
between the "Input String" text box and the argv array passed to the
worker. The decoder used U+0000 and U+0001 as internal placeholders and
dropped empty strings, so `splitUnescapedSpaces(joinWithEscaping(a))` was
not `a` for arguments containing those characters or for empty arguments.
When the page was opened via a crafted `?argv=...&interactive` link, the
text box was filled with the lossy re-encoding while synthesis ran on the
original argv, so the visitor saw one command line and ran another.
Rewrite the decoder as a character-by-character parser with no
placeholder characters. `\ ` and `\\` keep their meaning, `\"` is a
literal quote, and a bare `""` token is the empty argument; any other
backslash is kept literally, as before. The encoder emits `""` for an
empty argument and escapes the quotes of an argument that is literally
`""`. With the pair an exact inverse, the displayed string always decodes
to the argv that ran.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016Rbn2gww3MGhvrh52fNjpD1 parent 5691ca0 commit 1dde156
1 file changed
Lines changed: 27 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
23 | 29 | | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
33 | 49 | | |
34 | 50 | | |
35 | 51 | | |
36 | 52 | | |
37 | | - | |
| 53 | + | |
38 | 54 | | |
39 | 55 | | |
| 56 | + | |
40 | 57 | | |
41 | 58 | | |
42 | 59 | | |
| |||
0 commit comments