You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Stefan Fritsch <sf...@sfritsch.de> on 2009/12/22 22:54:45 UTC

Should ap_get_server_name() behave like get_server_name_for_url() for literal IPv6 addresses?

Hi,

mod_rewrite incorrectly omits the brackets around literal IPv6 
addresses in redirects. Similar issues have been fixed at other places 
in the code already. In server/core.c there is 
get_server_name_for_url(), a wrapper around ap_get_server_name, which 
adds the brackets.

I think making ap_get_server_name do the right thing would be better 
than introducing the same fix at many different places. I have found 
the following uses of ap_get_server_name:

mod_cache:
the cache key includes host:port and should probably have the brackets

mod_vhost_alias:
directory name (doesn't really matter, but change would be backward 
incompatible)

server/core.c:
server signature (doesn't matter)

mod_proxy_http:
via header (should have brackets)

ssl_engine_kernel.c:
error message url (should have brackets)

mod_rewrite:
redirects (should have brackets)
logging (doesn't matter)
SERVER_NAME variable

It's also used for the SERVER_NAME variable in:
ssl_engine_vars.c    
server/util_script.c
server/util_expr.c

I guess many scripts don't have a special case for IPv6 literals. I 
think having the brackets in the SERVER_NAME variable would be better. 
Is there some spec how this should be?


modules/proxy/ajp_header.c

sent as server_name to the backend. The AJP protocol specification 
doesn't say anything about this. Any idea?


mod_auth_digest.c

No idea. Can somebody with knowledge of digest auth check this?


What do you think about changing ap_get_server_name() in trunk?

Cheers,
Stefan

Re: Should ap_get_server_name() behave like get_server_name_for_url() for literal IPv6 addresses?

Posted by Stefan Fritsch <sf...@sfritsch.de>.
On Fri, 8 Jan 2010, Colm MacCárthaigh wrote:
>> mod_proxy_http:
>> via header (should have brackets)
>>
>> ssl_engine_kernel.c:
>> error message url (should have brackets)
>>
>> mod_rewrite:
>> redirects (should have brackets)
>> logging (doesn't matter)
>> SERVER_NAME variable
>
> Redirects should have brackets yes ... but I don't think that it's the
> job of the SERVER_NAME variable to anticipate potential use in a url,
> it's just a representation of an IPv6 address. Introducing braces
> would break reverse DNS lookups, for one thing.

DNS lookups are a valid point. Unless somebody disagrees, I will 
leave ap_get_server_name()/SERVER_NAME alone but create a public 
ap_get_server_name_for_url() function and use that where 
appropriate.

Re: Should ap_get_server_name() behave like get_server_name_for_url() for literal IPv6 addresses?

Posted by Colm MacCárthaigh <co...@allcosts.net>.
On Tue, Dec 22, 2009 at 9:54 PM, Stefan Fritsch <sf...@sfritsch.de> wrote:
> mod_rewrite incorrectly omits the brackets around literal IPv6
> addresses in redirects. Similar issues have been fixed at other places
> in the code already. In server/core.c there is
> get_server_name_for_url(), a wrapper around ap_get_server_name, which
> adds the brackets.

IPv6 addresses do have brackets in URLs, because colon is a port separator too,

...

> mod_proxy_http:
> via header (should have brackets)
>
> ssl_engine_kernel.c:
> error message url (should have brackets)
>
> mod_rewrite:
> redirects (should have brackets)
> logging (doesn't matter)
> SERVER_NAME variable

Redirects should have brackets yes ... but I don't think that it's the
job of the SERVER_NAME variable to anticipate potential use in a url,
it's just a representation of an IPv6 address. Introducing braces
would break reverse DNS lookups, for one thing.

> I guess many scripts don't have a special case for IPv6 literals. I
> think having the brackets in the SERVER_NAME variable would be better.
> Is there some spec how this should be?

I think encoding as per RFC3513 Section 2.2 is best :-)

-- 
Colm