Skip to content

Sheet: a model encoding that survives header trimming - #60

Merged
junjihashimoto merged 1 commit into
mainfrom
fix/sheet-model-encoding
Nov 29, 2026
Merged

junjihashimoto merged 1 commit into
mainfrom
fix/sheet-model-encoding

Conversation

@junjihashimoto

Copy link
Copy Markdown
Contributor

Problem

The Sheet example sends its model in the X-Model header and gets it back on the next step. An empty sheet with B2 selected encoded as B2<tab>. Browsers drop whitespace at either end of a header value, so the next step sent B2, which decodeModel rejected, and the page fell back to the initial model: the value went into the right cell, but the selection jumped back to A1. A cell value ending in a space, or holding ;, | or a tab, broke the same way. This was found from the aether side.

Change

  • encodeModel and decodeModel percent-encode each part with LeanTea.Auth.urlEncode, which leaves only letters, digits, -_.~ and %xx.
  • The separators are now / after the selected cell, , between cells and : inside a cell. Encoded text never contains them, so the line never starts or ends with whitespace and any value round-trips.

Tests

pure_spec has a new "Sheet model codec" group (3 checks), run on the encoded line after trimming it as a browser would:

  • an empty sheet round-trips;
  • values with spaces, tabs, separators, % and + round-trip;
  • the encoding never starts or ends with whitespace.

All three fail against the old codec, and pure_spec passes with the fix: 49 passed, 0 failed. sheet_serve builds.

The model travels in the X-Model header. An empty sheet encoded as
`B2<tab>`; browsers drop whitespace at the ends of a header value, so
the next step sent `B2`, which did not decode, and the page fell back to
the initial model (the selection jumped back to A1). A value ending in a
space, or holding `;`, `|` or a tab, broke the same way.

Each part is now percent-encoded, with `/`, `,` and `:` as separators,
so the line never starts or ends with whitespace and any value round
trips. pure_spec checks both cases after trimming, and that the line
has no whitespace at its ends; all three fail with the old codec.
@junjihashimoto
junjihashimoto merged commit 0d3726e into main Nov 29, 2026
1 check passed
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