[geary/wip/714317-hide-html-in-preview: 2/4] Remove hacks for MIME part headers when processing preview text.



commit 821ae7c987fb4459e8dac266ef2bc04d93e27dad
Author: Michael James Gratton <mike vee net>
Date:   Mon Dec 19 18:44:39 2016 +1100

    Remove hacks for MIME part headers when processing preview text.
    
    * src/engine/rfc822/rfc822-utils.vala (to_preview_text): Don't bother to
      check for MIME Content-* headers now that we are only treating a part
      as plain text if it is actually text/plain.

 src/engine/rfc822/rfc822-utils.vala       |   14 --------------
 test/engine/rfc822-message-data-test.vala |    2 +-
 test/engine/rfc822-utils-test.vala        |    2 +-
 3 files changed, 2 insertions(+), 16 deletions(-)
---
diff --git a/src/engine/rfc822/rfc822-utils.vala b/src/engine/rfc822/rfc822-utils.vala
index 2683c93..0e503ac 100644
--- a/src/engine/rfc822/rfc822-utils.vala
+++ b/src/engine/rfc822/rfc822-utils.vala
@@ -354,17 +354,8 @@ public string to_preview_text(string? text, TextFormat format) {
     if (format == TextFormat.PLAIN) {
         StringBuilder buf = new StringBuilder();
         string[] all_lines = text.split("\r\n");
-        bool in_mime_header = false;
         bool in_inline_pgp_header = false;
         foreach (string line in all_lines) {
-            if ((in_mime_header || in_inline_pgp_header) &&
-                line.has_prefix(" ") ||
-                line.has_prefix("\t")) {
-                continue; // Skip "folded" (multi-line) headers.
-            } else {
-                in_mime_header = false;
-            }
-
             if (in_inline_pgp_header) {
                 if (Geary.String.is_empty(line)) {
                     in_inline_pgp_header = false;
@@ -372,11 +363,6 @@ public string to_preview_text(string? text, TextFormat format) {
                 continue;
             }
 
-            if (line.has_prefix("Content-")) {
-                in_mime_header = true;
-                continue;
-            }
-
             if (line.has_prefix("-----BEGIN PGP SIGNED MESSAGE-----")) {
                 in_inline_pgp_header = true;
                 continue;
diff --git a/test/engine/rfc822-message-data-test.vala b/test/engine/rfc822-message-data-test.vala
index fdf819e..90cce91 100644
--- a/test/engine/rfc822-message-data-test.vala
+++ b/test/engine/rfc822-message-data-test.vala
@@ -36,7 +36,7 @@ class Geary.RFC822.MessageDataTest : Gee.TestCase {
 
     public static string PLAIN_BODY1_HEADERS = "Content-Type: text/plain; 
charset=\"us-ascii\"\r\nContent-Transfer-Encoding: 7bit\r\n";
 
-    public static string PLAIN_BODY1_ENCODED = "Content-Type: text/plain; 
charset=\"us-ascii\"\r\nContent-Transfer-Encoding: 7bit\r\n\r\n-----BEGIN PGP SIGNED MESSAGE-----\r\nHash: 
SHA512\r\n\r\n=============================================================================\r\nFreeBSD-EN-16:11.vmbus
                                          Errata Notice\r\n                                                   
       The FreeBSD Project\r\n\r\nTopic:          Avoid using spin locks for channel message 
locks\r\n\r\nCategory:       core\r\nModule:         vmbus\r\nAnnounced:      2016-08-12\r\nCredits:        
Microsoft OSTC\r\nAffects:        FreeBSD 10.3\r\nCorrected:      2016-06-15 09:52:01 UTC (stable/10, 
10.3-STABLE)\r\n                2016-08-12 04:01:16 UTC (releng/10.3, 10.3-RELEASE-p7)\r\n\r\nFor general 
information regarding FreeBSD Errata Notices and Security\r\nAdvisories, including descriptions of the fields 
above, security\r\nbranches, and the following sections, pleas
 e visit\r\n<URL:https://security.FreeBSD.org/>.\r\n";
+    public static string PLAIN_BODY1_ENCODED = "-----BEGIN PGP SIGNED MESSAGE-----\r\nHash: 
SHA512\r\n\r\n=============================================================================\r\nFreeBSD-EN-16:11.vmbus
                                          Errata Notice\r\n                                                   
       The FreeBSD Project\r\n\r\nTopic:          Avoid using spin locks for channel message 
locks\r\n\r\nCategory:       core\r\nModule:         vmbus\r\nAnnounced:      2016-08-12\r\nCredits:        
Microsoft OSTC\r\nAffects:        FreeBSD 10.3\r\nCorrected:      2016-06-15 09:52:01 UTC (stable/10, 
10.3-STABLE)\r\n                2016-08-12 04:01:16 UTC (releng/10.3, 10.3-RELEASE-p7)\r\n\r\nFor general 
information regarding FreeBSD Errata Notices and Security\r\nAdvisories, including descriptions of the fields 
above, security\r\nbranches, and the following sections, please 
visit\r\n<URL:https://security.FreeBSD.org/>.\r\n";
 
     public static string PLAIN_BODY1_EXPECTED = "FreeBSD-EN-16:11.vmbus Errata Notice The FreeBSD Project 
Topic: Avoid using spin locks for channel message locks Category: core Module: vmbus Announced: 2016-08-12 
Credits: Microsoft OSTC Affects: FreeBSD 10.3 Corrected: 2016-06-15 09:52:01 UTC (stable/10, 10.3-STABLE) 
2016-08-12 04:01:16 UTC (releng/10.3, 10.3-RELEASE-p7)";
 
diff --git a/test/engine/rfc822-utils-test.vala b/test/engine/rfc822-utils-test.vala
index af548ab..afc0ee0 100644
--- a/test/engine/rfc822-utils-test.vala
+++ b/test/engine/rfc822-utils-test.vala
@@ -21,7 +21,7 @@ class Geary.RFC822.Utils.Test : Gee.TestCase {
                HTML_BODY_EXPECTED.substring(0, Geary.Email.MAX_PREVIEW_BYTES));
     }
 
-    public static string PLAIN_BODY_ENCODED = "Content-Type: text/plain; 
charset=\"us-ascii\"\r\nContent-Transfer-Encoding: 7bit\r\n\r\n-----BEGIN PGP SIGNED MESSAGE-----\r\nHash: 
SHA512\r\n\r\n=============================================================================\r\nFreeBSD-EN-16:11.vmbus
                                          Errata Notice\r\n                                                   
       The FreeBSD Project\r\n\r\nTopic:          Avoid using spin locks for channel message 
locks\r\n\r\nCategory:       core\r\nModule:         vmbus\r\nAnnounced:      2016-08-12\r\nCredits:        
Microsoft OSTC\r\nAffects:        FreeBSD 10.3\r\nCorrected:      2016-06-15 09:52:01 UTC (stable/10, 
10.3-STABLE)\r\n                2016-08-12 04:01:16 UTC (releng/10.3, 10.3-RELEASE-p7)\r\n\r\nFor general 
information regarding FreeBSD Errata Notices and Security\r\nAdvisories, including descriptions of the fields 
above, security\r\nbranches, and the following sections, please
  visit\r\n<URL:https://security.FreeBSD.org/>.\r\n";
+    public static string PLAIN_BODY_ENCODED = "-----BEGIN PGP SIGNED MESSAGE-----\r\nHash: 
SHA512\r\n\r\n=============================================================================\r\nFreeBSD-EN-16:11.vmbus
                                          Errata Notice\r\n                                                   
       The FreeBSD Project\r\n\r\nTopic:          Avoid using spin locks for channel message 
locks\r\n\r\nCategory:       core\r\nModule:         vmbus\r\nAnnounced:      2016-08-12\r\nCredits:        
Microsoft OSTC\r\nAffects:        FreeBSD 10.3\r\nCorrected:      2016-06-15 09:52:01 UTC (stable/10, 
10.3-STABLE)\r\n                2016-08-12 04:01:16 UTC (releng/10.3, 10.3-RELEASE-p7)\r\n\r\nFor general 
information regarding FreeBSD Errata Notices and Security\r\nAdvisories, including descriptions of the fields 
above, security\r\nbranches, and the following sections, please 
visit\r\n<URL:https://security.FreeBSD.org/>.\r\n";
 
     public static string PLAIN_BODY_EXPECTED = "FreeBSD-EN-16:11.vmbus Errata Notice The FreeBSD Project 
Topic: Avoid using spin locks for channel message locks Category: core Module: vmbus Announced: 2016-08-12 
Credits: Microsoft OSTC Affects: FreeBSD 10.3 Corrected: 2016-06-15 09:52:01 UTC (stable/10, 10.3-STABLE) 
2016-08-12 04:01:16 UTC (releng/10.3, 10.3-RELEASE-p7)";
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]