Uploaded image for project: 'JBoss Web'
  1. JBoss Web
  2. JBWEB-190

TomcatResolver in RewriteValve can't resolve environment variable previously stored by a RewriteRule directive

    Details

    • Steps to Reproduce:
      Hide

      RewriteCond %

      {HTTP_HOST}

      ^(.*).foo.net$ [NC]
      RewriteRule .* $0 [E=subdomain:%1]

      1. news
        RewriteRule /news/(\d+) /% {ENV:subdomain}

        .do [L]

      Show
      RewriteCond % {HTTP_HOST} ^(.*).foo.net$ [NC] RewriteRule .* $0 [E=subdomain:%1] news RewriteRule /news/(\d+) /% {ENV:subdomain} .do [L]
    • Workaround:
      Workaround Exists
    • Workaround Description:
      Hide

      Index: TomcatResolver.java
      ===================================================================
      — TomcatResolver.java (revision 1594)
      +++ TomcatResolver.java (working copy)
      @@ -132,7 +132,8 @@
      }

      public String resolveEnv(String key)

      { - return System.getProperty(key); + String requestEnvVal = request.getAttribute(key).toString(); + return (requestEnvVal != null) ? requestEnvVal : System.getProperty(key); }

      public String resolveSsl(String key) {

      Show
      Index: TomcatResolver.java =================================================================== — TomcatResolver.java (revision 1594) +++ TomcatResolver.java (working copy) @@ -132,7 +132,8 @@ } public String resolveEnv(String key) { - return System.getProperty(key); + String requestEnvVal = request.getAttribute(key).toString(); + return (requestEnvVal != null) ? requestEnvVal : System.getProperty(key); } public String resolveSsl(String key) {
    • Estimated Difficulty:
      Low

      Description

      In the following test case, http://test.foo.net/news/123 will be rewrote into /null.do instead of /test.do

      RewriteCond %

      {HTTP_HOST}

      ^(.*).foo.net$ [NC]
      RewriteRule .* $0 [E=subdomain:%1]

      1. news
        RewriteRule /news/(\d+) /% {ENV:subdomain}

        .do [L]

      It seems that subdomain=test has been stored into request.attributes but TomcatResolver doesn't retrive subdomain from request.attributes but via System.getProperty

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                rmaucher Remy Maucherat
                Reporter:
                vivimice Wenwei Liao
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: