[pan] Try an autodetection strategy:



commit 50ea85a44adda47ec1f9b8069cf341b935fae420
Author: Olaf Seibert <rhialto falu nl>
Date:   Fri Feb 14 22:46:25 2020 +0100

    Try an autodetection strategy:
    
    If the filename from the body of the article cannot be found in the
    Subject, one or both is probably corrupt, and we override them.

 uulib/uulib.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
---
diff --git a/uulib/uulib.c b/uulib/uulib.c
index bef1cc4..1286f43 100644
--- a/uulib/uulib.c
+++ b/uulib/uulib.c
@@ -667,6 +667,7 @@ UULoadFileWithPartNo (char *filename, char *fileid, int delflag, int partno, con
   uufile *fload;
   itbd *killem;
   FILE *datei;
+  int overridden_subject;
 
   if ((datei = fopen (filename, "rb")) == NULL) {
     UUMessage (uulib_id, __LINE__, UUMSG_ERROR,
@@ -779,12 +780,21 @@ UULoadFileWithPartNo (char *filename, char *fileid, int delflag, int partno, con
       continue;
     }
 
-    if (partno != -1 && global_subject /*&& loaded->uudet == YENC_ENCODED*/) {
+    if (partno != -1 && global_subject &&
+        loaded->uudet == YENC_ENCODED && /* only yEnc has a filename in each part */
+        (loaded->subject && loaded->filename &&
+         strstr(loaded->subject, loaded->filename) == NULL)) {
       /*
        * Sometimes articles derived from an NZB file have corrupt Subject: lines.
        * That also makes that UUInsertPartToList() fails to combine files properly.
+       * We detect this situation by checking if the filename from the
+       * part can be found in the Subject: header.
        */
+      _FP_free(loaded->subject);
       loaded->subject = _FP_strdup((char *)global_subject);
+      overridden_subject = 1;
+    } else {
+      overridden_subject = 0;
     }
 
     if ((fload = UUPreProcessPart (loaded, &res)) == NULL) {
@@ -801,13 +811,14 @@ UULoadFileWithPartNo (char *filename, char *fileid, int delflag, int partno, con
       continue;
     }
 
-    if (partno != -1 && global_subject /*&& loaded->uudet == YENC_ENCODED*/) {
+    if (overridden_subject) {
       /*
        * If the yEnc file gives a different file name than the subject,
        * this is a security risk.
        *
        * Override the part file name with the one derived from the global subject.
        */
+      _FP_free(fload->filename);
       fload->filename = _FP_strdup(fload->subfname);
     }
 


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