@@ -649,7 +649,8 @@ impl<'x> MessagePart<'x> {
649649 /// Returns the body part's contents as a `u8` slice
650650 pub fn contents ( & self ) -> & [ u8 ] {
651651 match & self . body {
652- PartType :: Text ( text) | PartType :: Html ( text) => text. as_bytes ( ) ,
652+ PartType :: Text ( text) => text. as_bytes ( ) ,
653+ PartType :: Html ( text) => text. potentially_wrong_charset ( ) . as_bytes ( ) ,
653654 PartType :: Binary ( bin) | PartType :: InlineBinary ( bin) => bin. as_ref ( ) ,
654655 PartType :: Message ( message) => message. raw_message ( ) ,
655656 PartType :: Multipart ( _) => b"" ,
@@ -659,7 +660,8 @@ impl<'x> MessagePart<'x> {
659660 /// Returns the body part's contents as a `str`
660661 pub fn text_contents ( & self ) -> Option < & str > {
661662 match & self . body {
662- PartType :: Text ( text) | PartType :: Html ( text) => text. as_ref ( ) . into ( ) ,
663+ PartType :: Text ( text) => text. as_ref ( ) . into ( ) ,
664+ PartType :: Html ( text) => text. potentially_wrong_charset ( ) . as_ref ( ) . into ( ) ,
663665 PartType :: Binary ( bin) | PartType :: InlineBinary ( bin) => {
664666 std:: str:: from_utf8 ( bin. as_ref ( ) ) . ok ( )
665667 }
@@ -689,7 +691,8 @@ impl<'x> MessagePart<'x> {
689691 /// Returns the body part's length
690692 pub fn len ( & self ) -> usize {
691693 match & self . body {
692- PartType :: Text ( text) | PartType :: Html ( text) => text. len ( ) ,
694+ PartType :: Text ( text) => text. len ( ) ,
695+ PartType :: Html ( text) => text. potentially_wrong_charset ( ) . len ( ) ,
693696 PartType :: Binary ( bin) | PartType :: InlineBinary ( bin) => bin. len ( ) ,
694697 PartType :: Message ( message) => message. raw_message ( ) . len ( ) ,
695698 PartType :: Multipart ( _) => 0 ,
@@ -758,7 +761,7 @@ impl<'x> MessagePart<'x> {
758761 is_encoding_problem : self . is_encoding_problem ,
759762 body : match self . body {
760763 PartType :: Text ( v) => PartType :: Text ( v. into_owned ( ) . into ( ) ) ,
761- PartType :: Html ( v) => PartType :: Html ( v. into_owned ( ) . into ( ) ) ,
764+ PartType :: Html ( v) => PartType :: Html ( v. make_owned ( ) ) ,
762765 PartType :: Binary ( v) => PartType :: Binary ( v. into_owned ( ) . into ( ) ) ,
763766 PartType :: InlineBinary ( v) => PartType :: InlineBinary ( v. into_owned ( ) . into ( ) ) ,
764767 PartType :: Message ( v) => PartType :: Message ( v. into_owned ( ) ) ,
0 commit comments