Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 3 additions & 12 deletions src/headers/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@

use std::borrow::Cow;

use super::Header;
use crate::encoders::{
base64::base64_encode_mime,
encode::{get_encoding_type, EncodingType},
quoted_printable::quoted_printable_encode,
};

use super::Header;

/// Unstructured text e-mail header.
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
pub struct Text<'x> {
Expand All @@ -45,7 +44,7 @@ impl<'x> Header for Text<'x> {
fn write_header(
&self,
mut output: impl std::io::Write,
mut bytes_written: usize,
bytes_written: usize,
) -> std::io::Result<usize> {
match get_encoding_type(self.text.as_bytes(), true, false) {
EncodingType::Base64 => {
Expand Down Expand Up @@ -73,15 +72,7 @@ impl<'x> Header for Text<'x> {
}
}
EncodingType::None => {
for (pos, &ch) in self.text.as_bytes().iter().enumerate() {
if bytes_written >= 76 && ch.is_ascii_whitespace() && pos < self.text.len() - 1
{
output.write_all(b"\r\n\t")?;
bytes_written = 1;
}
output.write_all(&[ch])?;
bytes_written += 1;
}
output.write_all(self.text.as_bytes())?;
output.write_all(b"\r\n")?;
}
}
Expand Down