fix mime atom

This commit is contained in:
Quentin 2023-07-22 09:47:20 +02:00
parent d4b1853513
commit 75780c232b
Signed by: quentin
GPG key ID: E9602264D639FF68
3 changed files with 5 additions and 5 deletions

View file

@ -6,7 +6,7 @@ use nom::{
sequence::delimited, sequence::delimited,
}; };
use crate::text::whitespace::cfws; use crate::text::whitespace::cfws;
use crate::text::words::mime_token as token; use crate::text::words::mime_atom as token;
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq)]
pub enum Mechanism<'a> { pub enum Mechanism<'a> {

View file

@ -21,7 +21,7 @@ pub fn encoded_word(input: &[u8]) -> IResult<&[u8], EncodedWord> {
pub fn encoded_word_quoted(input: &[u8]) -> IResult<&[u8], EncodedWord> { pub fn encoded_word_quoted(input: &[u8]) -> IResult<&[u8], EncodedWord> {
let (rest, (_, charset, _, _, _, txt, _)) = tuple(( let (rest, (_, charset, _, _, _, txt, _)) = tuple((
tag("=?"), words::mime_token, tag("=?"), words::mime_atom,
tag("?"), one_of("Qq"), tag("?"), one_of("Qq"),
tag("?"), ptext, tag("?"), ptext,
tag("?=")))(input)?; tag("?=")))(input)?;
@ -33,7 +33,7 @@ pub fn encoded_word_quoted(input: &[u8]) -> IResult<&[u8], EncodedWord> {
pub fn encoded_word_base64(input: &[u8]) -> IResult<&[u8], EncodedWord> { pub fn encoded_word_base64(input: &[u8]) -> IResult<&[u8], EncodedWord> {
let (rest, (_, charset, _, _, _, txt, _)) = tuple(( let (rest, (_, charset, _, _, _, txt, _)) = tuple((
tag("=?"), words::mime_token, tag("=?"), words::mime_atom,
tag("?"), one_of("Bb"), tag("?"), one_of("Bb"),
tag("?"), btext, tag("?"), btext,
tag("?=")))(input)?; tag("?=")))(input)?;

View file

@ -30,8 +30,8 @@ pub enum MIMEWord<'a> {
impl<'a> MIMEWord<'a> { impl<'a> MIMEWord<'a> {
pub fn to_string(&self) -> String { pub fn to_string(&self) -> String {
match self { match self {
Quoted(v) => v.to_string(), Self::Quoted(v) => v.to_string(),
Atom(v) => encoding_rs::UTF_8.decode_without_bom_handling(v).1.to_string(), Self::Atom(v) => encoding_rs::UTF_8.decode_without_bom_handling(v).1.to_string(),
} }
} }
} }