diff options
author | Sam Scott <sam@osohq.com> | 2022-07-10 15:33:37 -0500 |
---|---|---|
committer | Sam Scott <sam@osohq.com> | 2022-07-10 15:33:37 -0500 |
commit | 0459c5e88e90e297ddb916ab96e62cdfaf7c3414 (patch) | |
tree | 5884a203471b2e7d99f6600a79227ef8da858aa9 | |
parent | 0c8dc4ae5382af826f6bc52b816dca37e48f7320 (diff) |
Formatting.
-rw-r--r-- | src/de/parse.rs | 31 | ||||
-rw-r--r-- | src/lib.rs | 6 |
2 files changed, 18 insertions, 19 deletions
diff --git a/src/de/parse.rs b/src/de/parse.rs index fe14bb4..20ba962 100644 --- a/src/de/parse.rs +++ b/src/de/parse.rs @@ -250,24 +250,23 @@ impl<'a> Parser<'a> { decoder.decode_utf8_lossy() }; - let ret: Result<Cow<'a, str>> = - match maybe_decoded { - Cow::Borrowed(_) => { - match replaced { - Cow::Borrowed(_) => { - // In this case, neither method made replacements, so we - // reuse the original bytes - let res = str::from_utf8(&self.inner[self.acc.0..self.acc.1 - 1])?; - Ok(Cow::Borrowed(res)) - } - Cow::Owned(owned) => { - let res = String::from_utf8(owned)?; - Ok(Cow::Owned(res)) - } + let ret: Result<Cow<'a, str>> = match maybe_decoded { + Cow::Borrowed(_) => { + match replaced { + Cow::Borrowed(_) => { + // In this case, neither method made replacements, so we + // reuse the original bytes + let res = str::from_utf8(&self.inner[self.acc.0..self.acc.1 - 1])?; + Ok(Cow::Borrowed(res)) + } + Cow::Owned(owned) => { + let res = String::from_utf8(owned)?; + Ok(Cow::Owned(res)) } } - Cow::Owned(owned) => Ok(Cow::Owned(owned)), - }; + } + Cow::Owned(owned) => Ok(Cow::Owned(owned)), + }; self.clear_acc(); ret.map_err(Error::from) } @@ -81,7 +81,7 @@ //! - 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`. @@ -101,9 +101,9 @@ //! 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 |