Skip to main content

percent_decode

Function percent_decode 

Source
fn percent_decode(value: &str) -> String
Expand description

Percent-decoding, with + as a space, as a query string is written.

A % that is not followed by two hex digits is left alone rather than refused: this decodes a parameter that is about to be looked up as a CID and fail on its own if it is nonsense, and there is nothing a decoding error could say that the lookup will not say better.

The escape is read as two bytes and never as a &str slice. A query string is only guaranteed to be UTF-8, not ASCII — http’s URI parser admits any byte above 0x7F as long as the path and query decode as UTF-8 — so a % followed by one ASCII byte and then a multi-byte character puts the end of a [index + 1..index + 3] slice inside that character, and slicing a str there panics. Nothing authenticates com.atproto.sync.getBlocks, which is what reads its parameters out of the raw query, so that panic was reachable by anyone who could reach the port.