Martin Mirchev created COMPRESS-736:
---------------------------------------

             Summary: Pack200 PackingOptions.isPassFile stops at the first 
non-matching directory rule
                 Key: COMPRESS-736
                 URL: https://issues.apache.org/jira/browse/COMPRESS-736
             Project: Commons Compress
          Issue Type: Bug
            Reporter: Martin Mirchev


{{PackingOptions.isPassFile(String)}} returns from the loop at the first 
directory rule (a pass entry that does not end in {{.class}}), whether or not 
it matches. A directory rule that does not match the file therefore hides every 
later rule, so a file named by a later exact rule, or under a later directory 
rule, is not passed through.

Reproducer:
{code:java}
PackingOptions options = new PackingOptions();
options.addPassFile("org/apache/other");
options.addPassFile("org/apache/Foo.class");
options.addPassFile("org/apache/pass");
options.isPassFile("org/apache/Foo.class");      // false, expected true
options.isPassFile("org/apache/pass/Bar.class"); // false, expected true
options.isPassFile("org/apache/other/Baz.class"); // true
{code}
With the {{org/apache/other}} rule added last instead, all three return true.

Suggested fix: return true when the directory rule matches and otherwise go on 
to the next rule. A pull request with the fix and a test follows.

This issue was found by an LLM-Enhanced Static Analysis Engine and verified 
manually.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to