jid: Test for too many @ before the resourcepart
This additionally should optimize the parsing a tiny bit by looking for both @ and / at the same time and iterating on them, instead of one by one. Thanks nicoco for the report!
This commit is contained in:
parent
772a326053
commit
f5f35eab20
3 changed files with 80 additions and 48 deletions
|
|
@ -46,6 +46,9 @@ pub enum Error {
|
|||
|
||||
/// Happens when parsing a bare JID and there is a resource.
|
||||
ResourceInBareJid,
|
||||
|
||||
/// Happens when parsing a JID which has two @ before the resource.
|
||||
TooManyAts,
|
||||
}
|
||||
|
||||
impl core::error::Error for Error {}
|
||||
|
|
@ -64,6 +67,7 @@ impl fmt::Display for Error {
|
|||
Error::ResourcePrep => "resource doesn’t pass resourceprep validation",
|
||||
Error::ResourceMissingInFullJid => "no resource found in this full JID",
|
||||
Error::ResourceInBareJid => "resource found while parsing a bare JID",
|
||||
Error::TooManyAts => "second @ found before parsing the resource",
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue