You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Steffen Heil (Mailinglisten)" <li...@steffen-heil.de> on 2013/03/02 19:53:46 UTC

Small bug in Tomcat and interest in wildcard patch

Hi

I looked into the source of tomcat 7 (7.0.x trunk) to extend it to support
wildcard aliases (such as *.example.com).
I found the class org.apache.tomcat.util.http.mapper.Mapper.
Looking at it, I found a small bug (lines 210-213):

        if (pos < 0) {
            log.error("No host found: " + hostName);
        }
        Host mappedHost = hosts[pos];

This can of course raise an IndexOutOfBoundsException.
But that's not the point of this mail.

I have non-optimal patch that extends the feature I need but that patch is
not optimal.
Is there any interest for that feature in the community and any chance to
get such a patch accepted into the codebase?

Then I would do some cleanups and improvements and publish the patch.

I would do with the following constraints:
- Wildcards would be automatically detected. (Just use hostnames starting
with "*.")
- As long as no wildcards are defined, there would be no performance penalty
for the patch.
- Wildcard processing would be as fast as possible.
- Wildcards would match any number of subdomains (*.example.com would match
a.b.c.d.example.com, but not example.com)
- Direct matches would always have precedence as do narrower wildcards.
Still open for suggestions.

So again:
Is there any interest for that feature in the community and any chance to
get such a patch accepted into the codebase?

Regards,
   Steffen


Re: Small bug in Tomcat and interest in wildcard patch

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Steffen,

On 3/2/13 1:53 PM, Steffen Heil (Mailinglisten) wrote:
> Is there any interest for that feature in the community and any
> chance to get such a patch accepted into the codebase?

There's always this:

https://issues.apache.org/bugzilla/show_bug.cgi?id=18500

It's been open for a while, and I never got around to actually rolling
and submitting a patch. The idea was that regular expressions would be
more flexible than simple prefixes, and my plan was to write something
that would switch the behavior of the existing code when the first
regex-based pattern was encountered. That way, no loss of performance
would occur unless regexes were used. A similar technique could be
used for simple prefix-matching after a bit of re-factoring
(essentially making the hostname-matcher plugable: the existing one, a
prefix-matching one (which could use the existing one as a
sub-matcher) and a regular-expression-based one.

Thanks,
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iEYEAREIAAYFAlEyojkACgkQ9CaO5/Lv0PCDPgCfa/gGpmQcG7en7uBCvN4YPA0R
ixoAnRRLHoApp1d6verQT/eruzzqjH2/
=YtFq
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Small bug in Tomcat and interest in wildcard patch

Posted by Mark Thomas <ma...@apache.org>.
On 02/03/2013 18:53, Steffen Heil (Mailinglisten) wrote:
> Hi
> 
> I looked into the source of tomcat 7 (7.0.x trunk) to extend it to support
> wildcard aliases (such as *.example.com).
> I found the class org.apache.tomcat.util.http.mapper.Mapper.
> Looking at it, I found a small bug (lines 210-213):
> 
>         if (pos < 0) {
>             log.error("No host found: " + hostName);
>         }
>         Host mappedHost = hosts[pos];
> 
> This can of course raise an IndexOutOfBoundsException.

Please create a Bugzilla entry for that. If you wanted to provide a
patch to fix it as well, that would be great.

> I have non-optimal patch that extends the feature I need but that patch is
> not optimal.
> Is there any interest for that feature in the community and any chance to
> get such a patch accepted into the codebase?

It is a long-standing enhancement request. At $work I have customers
interested in this feature. If it was felt that the feature would never
be included, the enhancement request would have been closed as WONTFIX.

> Then I would do some cleanups and improvements and publish the patch.
> 
> I would do with the following constraints:
> - Wildcards would be automatically detected. (Just use hostnames starting
> with "*.")
> - As long as no wildcards are defined, there would be no performance penalty
> for the patch.

Good. That is probably essential to get any patch accepted.

> - Wildcard processing would be as fast as possible.

:)

> - Wildcards would match any number of subdomains (*.example.com would match
> a.b.c.d.example.com, but not example.com)

OK.

> - Direct matches would always have precedence as do narrower wildcards.

Seems reasonable.

> Still open for suggestions.

I like that you have clearly defined the expected behaviour. That is a
big plus. The changes would need some documentation.

> So again:
> Is there any interest for that feature in the community and any chance to
> get such a patch accepted into the codebase?

Yes and yes.

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org