🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: news.software.readers
1 messages
1 total messages Started by Michael Bäuerle Tue, 02 Aug 2016 10:00
[KNode] References trimming
#260842
Author: Michael Bäuerle
Date: Tue, 02 Aug 2016 10:00
77 lines
3693 bytes
The following "RefTrim" patch for KNode 4.14.10 fixes the problem
that follow-ups into deep threads may exceed the length limit of the
References header field defined by RFC5537.

---------------------------------------------------------------------------------------------------------------------------------------
diff -ruN kdepim-4.14.10/knode/knarticlefactory.cpp kdepim-4.14.10_RefTrim/knode/knarticlefactory.cpp
--- kdepim-4.14.10/knode/knarticlefactory.cpp	2015-06-25 19:47:38.000000000 +0200
+++ kdepim-4.14.10_RefTrim/knode/knarticlefactory.cpp	2016-07-05 20:36:18.000000000 +0200
@@ -46,6 +46,10 @@
 #include <mailtransport/transportmanager.h>
 
 
+// 2016-07-05: Enable patch to trim References header field
+#define REFTRIM  1
+
+
 using namespace KNode;
 using namespace KNode::Utilities;
 using namespace MailTransport;
@@ -185,6 +189,43 @@
   art->references()->from7BitString(refs);
   art->references()->appendIdentifier(a->messageID()->as7BitString(false));
 
+#if REFTRIM
+  // According to RFC5537 the References header field must be trimmed if too long:
+  // https://tools.ietf.org/html/rfc5537#section-3.4.4
+  references=art->references(false);
+  if (references)
+  {
+    refs = references->as7BitString(true);
+    if (998 < refs.size())
+    {
+      // Skip first Message-ID
+      int start = refs.indexOf('>') + 1;
+      int end;
+      if (1 < start)
+      {
+        while (998 < refs.size())
+        {
+          //printf("Remove ref\n");
+          end = refs.indexOf('>', start) + 1;
+          refs.remove(start, end - start);
+        }
+      }
+      if (998 < refs.size())
+        KMessageBox::information(knGlobals.topWidget, i18n("References trimming failed"), QString(), "refTrimError");
+      else
+      {
+        // Success, strip field name
+        end = refs.indexOf('<');
+        if (0 < end)
+          refs.remove(0, end);
+        //printf("Refs: %s\n", refs.data());
+        art->references()->from7BitString(refs);
+        KMessageBox::information(knGlobals.topWidget, i18n("References were trimmed according to RFC5537"), QString(), "refTrimNote");
+      }
+    }
+  }
+#endif  // REF_TRIM
+
   //Mail-Copies-To
   bool authorDislikesMailCopies=false;
   bool authorWantsMailCopies=false;
@@ -840,7 +881,11 @@
 
   //User-Agent
   if( !knGlobals.settings()->noUserAgent() ) {
-    art->userAgent()->from7BitString("KNode/" KNODE_VERSION);
+    art->userAgent()->from7BitString("KNode/" KNODE_VERSION
+#if REFTRIM
+    " (with RefTrim patch)"
+#endif  // REFTRIM
+    );
   }
 
   //Mime
---------------------------------------------------------------------------------------------------------------------------------------
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads