Forum

IPv6 related garbage in $_SERVER['HTTP_HOST']

Allen Stambaugh
16 September 2010, 02:48
Hiawatha version: v7.3
Operating System: Windows Vista

I use the following PHP script to find out if a web server is spewing garbage.

<?php
echo '<html><head><title>Plain garbage</title></head><body><p><tt>';
echo 'SERVER_SOFTWARE: ' . $_SERVER['SERVER_SOFTWARE'];
echo '<br/>';
echo 'PHP version: ' . phpversion();
echo '<br/><br/>';
echo 'SERVER_NAME: ' . $_SERVER['SERVER_NAME'];
echo '<br/>';
echo 'HOSTNAME: ' . $_SERVER['HOSTNAME'];
echo '<br/>';
echo 'HTTP_HOST: ' . $_SERVER['HTTP_HOST'];
echo '<br/>';
echo 'SERVER_ADDR: ' . $_SERVER['SERVER_ADDR'];
echo '</tt></p></body></html>';
?>

This is what I got back.

SERVER_SOFTWARE: Hiawatha v7.3
PHP version: 5.3.3

SERVER_NAME: localhost
HOSTNAME:
HTTP_HOST: [2001
SERVER_ADDR:

It looks like Hiawatha is clipping everything off after the first colon. The value of HTTP_HOST should have been [2001:470:a:18f::2]. This bug also appears in version 6.17.1 as installed with Puppy 5.1.1.
Hugo Leisink
20 September 2010, 08:58
I'll take a look at it. Thanks for this bug report.
Allen Stambaugh
2 October 2010, 16:53
I will leave my web server up until about 4pm (PDT) today. The URL is http://[2001:470:a:18f::2]/plaingarbage.php.
Hugo Leisink
2 October 2010, 19:03
I don't have a properly working IPv6 connection with the internet. So, I can't look at the webpage via the given URL.
Allen Stambaugh
3 October 2010, 02:20
I have sent you an email.
Hugo Leisink
8 October 2010, 08:34
Thanks for reporting the issue. It will be fixed in the next release. In the meantime, you can use the following fix. In serverconfig.c in get_hostrecord(), you can remove the following code:
if ((dots = strchr(hostname, ':')) != NULL) {
*dots = '\0';
}
This topic has been closed.