This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit d11cf04c07dae0b66c7b77d732856eb6a9e91085
Author: Benoit TELLIER <[email protected]>
AuthorDate: Thu Nov 28 15:37:59 2024 +0100

    [ENHANCEMENT] Extract partMatchLogic
---
 .../transport/matchers/AttachmentFileNameIs.java   | 33 +++++++++++++---------
 1 file changed, 20 insertions(+), 13 deletions(-)

diff --git 
a/mailet/standard/src/main/java/org/apache/james/transport/matchers/AttachmentFileNameIs.java
 
b/mailet/standard/src/main/java/org/apache/james/transport/matchers/AttachmentFileNameIs.java
index 8abbc62233..f5d6f5ec86 100755
--- 
a/mailet/standard/src/main/java/org/apache/james/transport/matchers/AttachmentFileNameIs.java
+++ 
b/mailet/standard/src/main/java/org/apache/james/transport/matchers/AttachmentFileNameIs.java
@@ -204,19 +204,8 @@ public class AttachmentFileNameIs extends GenericMatcher {
                 } // remember any messaging exception and process next bodypart
             }
         } else {
-            String fileName = part.getFileName();
-            if (fileName != null) {
-                fileName = cleanFileName(fileName);
-                // check the file name
-                if (matchFound(fileName)) {
-                    if (mimeWalkConfiguration.isDebug()) {
-                        LOGGER.debug("matched {}", fileName);
-                    }
-                    return true;
-                }
-                if (mimeWalkConfiguration.unzipIsRequested() && 
fileName.endsWith(ZIP_SUFFIX) && matchFoundInZip(part)) {
-                    return true;
-                }
+            if (partMatch(part)) {
+                return true;
             }
         }
         
@@ -228,6 +217,24 @@ public class AttachmentFileNameIs extends GenericMatcher {
         return false;
     }
 
+    private boolean partMatch(Part part) throws MessagingException, 
IOException {
+        String fileName = part.getFileName();
+        if (fileName != null) {
+            fileName = cleanFileName(fileName);
+            // check the file name
+            if (matchFound(fileName)) {
+                if (mimeWalkConfiguration.isDebug()) {
+                    LOGGER.debug("matched {}", fileName);
+                }
+                return true;
+            }
+            if (mimeWalkConfiguration.unzipIsRequested() && 
fileName.endsWith(ZIP_SUFFIX) && matchFoundInZip(part)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
     /**
      * Checks if <I>fileName</I> matches with at least one of the 
<CODE>masks</CODE>.
      * 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to