diff options
| author | Jeremiah Senkpiel <fishrock123@rocketmail.com> | 2022-07-09 18:02:44 -0700 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-07-09 20:02:44 -0500 | 
| commit | f26bdc9109abffc86ea78bb85cf3504a771d17ad (patch) | |
| tree | dbd543924da72c713578f8cb28e6facebcf04e5d /src/lib.rs | |
| parent | 3ddcd171ea66efa94821533299f48788a18fb33a (diff) | |
feat: non-strict mode replaces invalid UTF-8 (#62)
This change makes non-strict mode percent-decode utf-8 lossily.
This means that invalid UTF-8 percent encoded sequences, such as `%E9`, are
decoded as the unicode replacement character (� `U+FFFD`).
Refs: https://github.com/samscott89/serde_qs/issues/43
Diffstat (limited to 'src/lib.rs')
| -rw-r--r-- | src/lib.rs | 19 | 
1 files changed, 16 insertions, 3 deletions
| @@ -75,9 +75,14 @@  //! ## Strict vs Non-Strict modes  //!  //! `serde_qs` supports two operating modes, which can be specified using -//! [`Config`](struct.Config.html), and is all about how `serde_qs` handles square brackets. -//! -//! Techncially, square brackets should be encoded in URLs as `%5B` and `%5D`. +//! [`Config`](struct.Config.html). +//! Strict mode has two parts: +//! - how `serde_qs` handles square brackets +//! - how `serde_qs` handles invalid UTF-8 percent decoded characters +//! +//! ### Square Brackets +//!  +//! Technically, square brackets should be encoded in URLs as `%5B` and `%5D`.  //! However, they are often used in their raw format to specify querystrings  //! such as `a[b]=123`.  //! @@ -96,6 +101,14 @@  //! automatically encodes the brackets. But care must be taken to avoid  //! using keys with square brackets in them, or unexpected things can  //! happen. +//!  +//! ### Invalid UTF-8 Percent Encodings +//!  +//! Sometimes querystrings may have percent-encoded data which does not decode +//! to UTF-8. In some cases it is useful for this to cause errors, which is how +//! `serde_qs` works in strict mode (the default). Whereas in other cases it +//! can be useful to just replace such data with the unicode replacement +//! character (� `U+FFFD`), which is how `serde_qs` works in non-strict mode.  //!  //! ## Flatten workaround  //! | 
