Skip to content

Commit

Permalink
Merge pull request #22 from Thomasdezeeuw/fix-panic
Browse files Browse the repository at this point in the history
Handle a single qoute in local part of email
  • Loading branch information
johnstonskj authored Jul 4, 2024
2 parents b3e5205 + 0e13b3c commit 0db031c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,8 @@ fn parse_local_part(part: &str) -> Result<(), Error> {
} else if part.len() > LOCAL_PART_MAX_LENGTH {
Error::LocalPartTooLong.into()
} else if part.starts_with(DQUOTE) && part.ends_with(DQUOTE) {
if part.len() == 2 {
// <= to handle `part` = `"` (single quote).
if part.len() <= 2 {
Error::LocalPartEmpty.into()
} else {
parse_quoted_local_part(&part[1..part.len() - 1])
Expand Down Expand Up @@ -1093,6 +1094,11 @@ mod tests {
Error::LocalPartEmpty,
Some("local-part is empty"),
);
expect(
"\"@example.com",
Error::LocalPartEmpty,
Some("local-part is empty"),
);
}

#[test]
Expand Down

0 comments on commit 0db031c

Please sign in to comment.