Error on invalid localpart
This commit is contained in:
parent
e8f7bd9f6d
commit
ad48d3972e
@ -81,14 +81,15 @@ fn parse_id(id: &str, valid_sigils: &[char]) -> Result<NonZeroU8, Error> {
|
|||||||
validate_id(id, valid_sigils)?;
|
validate_id(id, valid_sigils)?;
|
||||||
|
|
||||||
let colon_idx = id.find(':').ok_or(Error::MissingDelimiter)?;
|
let colon_idx = id.find(':').ok_or(Error::MissingDelimiter)?;
|
||||||
|
if colon_idx < 2 {
|
||||||
|
return Err(Error::InvalidLocalPart);
|
||||||
|
}
|
||||||
|
|
||||||
if !is_valid_server_name(&id[colon_idx + 1..]) {
|
if !is_valid_server_name(&id[colon_idx + 1..]) {
|
||||||
return Err(Error::InvalidServerName);
|
return Err(Error::InvalidServerName);
|
||||||
}
|
}
|
||||||
|
|
||||||
match NonZeroU8::new(colon_idx as u8) {
|
Ok(NonZeroU8::new(colon_idx as u8).unwrap())
|
||||||
Some(idx) => Ok(idx),
|
|
||||||
None => Err(Error::InvalidLocalPart),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Deserializes any type of id using the provided TryFrom implementation.
|
/// Deserializes any type of id using the provided TryFrom implementation.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user