pub fn parse<'a>(
value: &'a [u8],
limits: &Limits,
) -> Result<ContentDisposition<'a>, ParseError>Expand description
Parses disposition-type *( OWS ";" OWS disposition-parm ).
The type token is case-insensitive. Repeated parameter names are refused
whatever limits says (a repeated filename is a known differential). A
filename* value must be an RFC 8187 value that decodes (valid UTF-8, no
control character); an invalid one refuses the whole field instead of
falling back to filename silently.
§Errors
ErrorKind::NotToken for the type; the parameter errors, with
ErrorKind::DuplicateParameter; the ExtValue::parse errors for
filename*; ErrorKind::TrailingData.
§Examples
use parse_net::{disposition, ErrorKind, Limits};
let dup = disposition::parse(b"attachment; filename=a.txt; filename=a.exe", &Limits::DEFAULT);
assert_eq!(dup.unwrap_err().kind(), ErrorKind::DuplicateParameter);
let bad = disposition::parse(b"attachment; filename=a.txt; filename*=UTF-8''%ZZ", &Limits::DEFAULT);
assert_eq!(bad.unwrap_err().kind(), ErrorKind::InvalidPercentEncoding);