🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #90701

[PATCH]: SLRN: include Injection headers in new score.

#90701
From: Kaz Kylheku
Date: Mon, 28 Aug 2023 19:57
97 lines
3674 bytes
This patch affects editing of the score file. Usenet suffers from a lot
of Google Groups spam, and it is often identified well through the
Injection*: headers.  These headers are not propagated to the score
file, so I've had to manually copy and paste, which is annoying.

This change makes slrn scan through the list of additional headers and
pick out anything that starts with "Injection" or contains
"Posting-Host". (Note that I'm not seeing the NNTP-Posting-Host header
show up in the list, but if that is fixed, it will be included.)

I sent the patch upstream to J.E.D.

From c84453f2def8f78721d4f31166c1e75568a2fd90 Mon Sep 17 00:00:00 2001
From: Kaz Kylheku <kaz@kylheku.com>
Date: Mon, 28 Aug 2023 00:01:05 -0700
Subject: [PATCH 2/2] Include Injection headers when editing scores.

Google Groups posts contain headers that are useful in
filtering, identifying the account and IP address.
SLRN should propagate these to the score file to make
it easier to make use of them.

* src/editscore.c (slrn_edit_score):Walk the additional
headers in h->add_hdrs. If the name of any header starts
with "Inject" or contain "Posting-Host", then include it.
---
 src/editscore.c | 43 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)

diff --git a/src/editscore.c b/src/editscore.c
index 5c7d2df..ba1d022 100644
--- a/src/editscore.c
+++ b/src/editscore.c
@@ -186,6 +186,8 @@ int slrn_edit_score (Slrn_Header_Type *h, char *newsgroup)
 
    if (Slrn_Prefix_Arg_Ptr == NULL)
      {
+	Slrn_Header_Line_Type *ah_iter;
+
 	char *line;
 	int comment;
 	linenum = 1;
@@ -292,6 +294,47 @@ int slrn_edit_score (Slrn_Header_Type *h, char *newsgroup)
 	     fprintf (fp, "%%\tNewsgroup: %s\n", q);
 	  }
 
+
+	for (ah_iter = h->add_hdrs; ah_iter != NULL; ah_iter = ah_iter->next)
+	  {
+	     char *value = ah_iter->value;
+	     char *name = ah_iter->name;
+
+	     if (name == NULL || value == NULL)
+		continue;
+
+	     if (strncmp(name, "Inject", 6) != 0 &&
+		 strstr(name, "Posting-Host") == 0)
+		continue;
+
+	     line = slrn_safe_strmalloc (value);
+	     remove_linebreaks (line);
+	     if ((NULL == (q = SLregexp_quote_string (line, qregexp, sizeof (qregexp)))) ||
+		 (ch != 'f') ||
+#if SLANG_VERSION < 20000
+		 (0 != SLang_regexp_compile (&re))
+#else
+		 (NULL == (re = SLregexp_compile (qregexp, SLREGEXP_CASELESS)))
+#endif
+		 )
+	       {
+		  re_error |= (ch == 'f');
+		  comment = 1;
+	       }
+	     else
+	       comment = 0;
+	     fprintf (fp, "%c\t%s: %s\n",
+		      (comment ? '%' : ' '), ah_iter->name, (q ? q : line));
+	     slrn_free (line);
+#if SLANG_VERSION >= 20000
+	     if (re != NULL)
+	       {
+		  SLregexp_free (re);
+		  re = NULL;
+	       }
+#endif
+	  }
+
 	fprintf (fp, "%%EOS\n");
 	file_modified = 1;
      }
-- 
2.17.1

-- 
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca
Technical Details
Message-ID: <20230828125422.870@kylheku.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!apf1.newsdeef.eu!not-for-mail

Show Full Headers
Complete Article Headers
Message-ID: <20230828125422.870@kylheku.com>
Subject: [PATCH]: SLRN: include Injection headers in new score.
Date: Mon, 28 Aug 2023 19:57:35 +0000
From: Kaz Kylheku <864-117-4973@kylheku.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!apf1.newsdeef.eu!not-for-mail
Newsgroups: news.software.nntp
Organization: A noiseless patient Spider
Lines: 97
Injection-Date: Mon, 28 Aug 2023 19:57:35 -0000 (UTC)
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:hHmc3Xoz/6kS18NlTsGgDtdnMm0=