You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2019/07/24 19:11:58 UTC

[Bug 63608] New: Negative pattern match in rewrite rule is not as documented

https://bz.apache.org/bugzilla/show_bug.cgi?id=63608

            Bug ID: 63608
           Summary: Negative pattern match in rewrite rule is not as
                    documented
           Product: Tomcat 8
           Version: 8.5.x-trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Catalina
          Assignee: dev@tomcat.apache.org
          Reporter: michaelc@hotmail.com
  Target Milestone: ----

The mention of using "NOT character ('!')" in rule patterns as negative match
no longer matches implementation:

https://tomcat.apache.org/tomcat-8.5-doc/rewrite.html

    In the rules, the NOT character ('!') is also available as a possible
pattern prefix. This enables you to negate a pattern; to say, for instance:
``if the current URL does NOT match this pattern''. This can be used for
exceptional cases, where it is easier to match the negative pattern, or as a
last default rule.


The current implementation uses java.util.regex, which does not support a
simple ! prefix as a negative match regex:

https://docs.oracle.com/javase/8/docs/api/index.html?java/util/regex/Pattern.html

Instead, you need to use zero-width lookahead like this (to match any URL but
/portal/api/.*)

^(?!/portal/api/.*).*$

This inaccurate documentation exist in all versions, at least since 8.0.x. For
backward compatibility to the above documentation, RewriteRule needs the
`positive` variable and logic found in the RewriteCond class.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 63608] Negative pattern match in rewrite rule is not as documented

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=63608

Mark Thomas <ma...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #1 from Mark Thomas <ma...@apache.org> ---
Thanks for the report.

Fixed in:
- master for 9.0.23 onwards
- 8.5.x for 8.5.44 onwards

The RewriteValve is not present in 7.0.x

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org