Escape : and % in the signed and cached path and query (closes #247)
check / check (push) Canceled after 0s

The signed data and the cache key joined host, path and query with ":"
and no escaping, so path /a:b with no query and path /a with query b:
gave the same string: a URL signed for one verified for the other, and
whichever was fetched first was served for both. Both now write each "%"
in the path and query as "%25" and each ":" as "%3A" before joining them.
A path and query holding neither are signed and keyed as before.
"Signature Specification" in README.md states the escaping.

Model: opus-5-5
This commit is contained in:
2026-10-15 05:38:34 +00:00
parent c4015858fa
commit 6209798793
4 changed files with 43 additions and 10 deletions
+5 -2
View File
@@ -419,8 +419,11 @@ HMAC-SHA256(secret, "host:path:query:width:height:format:expiration:quality:fit"
Where:
- `host` — source origin hostname (e.g. `cdn.example.com`)
- `path` — source path (e.g. `/photos/cat.jpg`)
- `query` — source query string, empty string if none
- `path` — source path (e.g. `/photos/cat.jpg`), with each `%` written as `%25`
and each `:` as `%3A`, so `/photos/a:b.jpg` is signed as `/photos/a%3Ab.jpg`
- `query` — source query string, empty string if none, with `%` and `:` written
as in `path`; neither then holds a `:`, so path `/a:b` with no query and path
`/a` with query `b:` are signed differently
- `width` — requested width in pixels, `0` for original
- `height` — requested height in pixels, `0` for original
- `format` — output format, one of those listed under Routes, with `original`