diff --git a/src/html.rs b/src/html.rs index 1350796f6..e32ee4357 100644 --- a/src/html.rs +++ b/src/html.rs @@ -283,7 +283,6 @@ mod tests { This message does not have Content-Type nor Subject.
-
"# ); @@ -302,7 +301,6 @@ This message does not have Content-Type nor Subject.
message with a non-UTF-8 encoding: äöüßÄÖÜ
-
"# ); @@ -325,7 +323,6 @@ This line ends with a space and will be merged with the next one due to format=f
This line does not end with a space
and will be wrapped as usual.
-
"# ); @@ -347,7 +344,6 @@ mime-modified should not be set set as there is no html and no special stuff;
test some special html-characters as < > and & but also " and ' :)

-
"# ); diff --git a/src/mimeparser.rs b/src/mimeparser.rs index e1f5ec1f8..095d4e12f 100644 --- a/src/mimeparser.rs +++ b/src/mimeparser.rs @@ -3708,6 +3708,28 @@ On 2020-10-25, Bob wrote: Ok(()) } + /// Tests that sender status (signature) does not appear + /// in HTML view of a long message. + #[tokio::test(flavor = "multi_thread", worker_threads = 2)] + async fn test_large_message_no_signature() -> Result<()> { + let mut tcm = TestContextManager::new(); + let alice = &tcm.alice().await; + let bob = &tcm.bob().await; + + alice + .set_config(Config::Selfstatus, Some("Some signature")) + .await?; + let chat = alice.create_chat(bob).await; + let txt = "Hello!\n".repeat(500); + let sent = alice.send_text(chat.id, &txt).await; + let msg = bob.recv_msg(&sent).await; + + assert_eq!(msg.has_html(), true); + let html = msg.id.get_html(bob).await?.unwrap(); + assert_eq!(html.contains("Some signature"), false); + Ok(()) + } + #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_x_microsoft_original_message_id() { let t = TestContext::new_alice().await; diff --git a/src/plaintext.rs b/src/plaintext.rs index 0c18fa104..d59ac80a5 100644 --- a/src/plaintext.rs +++ b/src/plaintext.rs @@ -2,7 +2,7 @@ use once_cell::sync::Lazy; -use crate::simplify::split_lines; +use crate::simplify::remove_message_footer; /// Plaintext message body together with format=flowed attributes. #[derive(Debug)] @@ -32,7 +32,8 @@ impl PlainText { regex::Regex::new(r"\b((http|https|ftp|ftps):[\w.,:;$/@!?&%\-~=#+]+)").unwrap() }); - let lines = split_lines(&self.text); + let lines: Vec<&str> = self.text.lines().collect(); + let (lines, _footer) = remove_message_footer(&lines); let mut ret = r#" @@ -136,7 +137,28 @@ line 1
line 2
line with https://link-mid-of-line.org and http://link-end-of-line.com/file?foo=bar%20
http://link-at-start-of-line.org
-
+ +"# + ); + } + + #[test] + fn test_plain_remove_signature() { + let html = PlainText { + text: "Foo\nbar\n-- \nSignature here".to_string(), + flowed: false, + delsp: false, + } + .to_html(); + assert_eq!( + html, + r#" + + + + +Foo
+bar
"# ); diff --git a/src/simplify.rs b/src/simplify.rs index 85e33b3e9..6932a9679 100644 --- a/src/simplify.rs +++ b/src/simplify.rs @@ -21,7 +21,9 @@ pub fn escape_message_footer_marks(text: &str) -> String { /// `footer_lines` is set to `Some` if the footer was actually removed from `lines` /// (which is equal to the input array otherwise). #[allow(clippy::indexing_slicing)] -fn remove_message_footer<'a>(lines: &'a [&str]) -> (&'a [&'a str], Option<&'a [&'a str]>) { +pub(crate) fn remove_message_footer<'a>( + lines: &'a [&str], +) -> (&'a [&'a str], Option<&'a [&'a str]>) { let mut nearly_standard_footer = None; for (ix, &line) in lines.iter().enumerate() { match line {