hypermail-project / hypermail

Hypermail is a free (GPL) program to convert email from Unix mbox format to html.
http://www.hypermail-project.org/
GNU General Public License v2.0
156 stars 73 forks source link

spamify_replacedomain() - incorrect handling of addresses ins de <> #2

Closed xipmix closed 1 year ago

xipmix commented 11 years ago
If input is a string like "<fred@example.com>\n", we need to take
care to substitute just the domain part, and not simply everthing
from the @ sign to the end of the string, lest we end up with e.g.
"<fred_at_nospam_maam".

---
 src/getname.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/src/getname.c b/src/getname.c
index 2001cd3..8158042 100644
--- a/src/getname.c
+++ b/src/getname.c
@@ -57,6 +57,7 @@ char *spamify_replacedomain(char *input, char *antispamdomain)
     int domainlen = strlen(antispamdomain);

     char *atptr = strchr(input, '@');
+    char *gtptr = strchr(input, '>');

     if (domainlen > 0) {
         newlen = newlen + domainlen;
@@ -72,6 +73,12 @@ char *spamify_replacedomain(char *input, char *antispamdomain)
         if (domainlen > 0) {
             /* append the new domain */
             strcpy(newbuf + index + strlen(set_antispam_at), antispamdomain);
+            /* handle possible '>' character after the domain */
+            if (gtptr) {
+                int i = gtptr - atptr;
+                if (i > 0)
+                    strcpy(newbuf + index + strlen(set_antispam_at) + strlen(antispamdomain), gtptr);
+            }
         }
         else {
             /* append the part after the @ */
-- 
1.7.2.5
jkbzh commented 1 year ago

As far as I can tell and test, this issue was already fixed (at least in 3.0), but the issue had never been closed. Thanks for your report and sorry for the delay.