Re: PHP 4.0 Bug #8552 Updated: fopen doesn't open URL

From: Date: Thu, 04 Jan 2001 21:52:59 +0000
Subject: Re: PHP 4.0 Bug #8552 Updated: fopen doesn't open URL
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-42989@lists.php.net to get a copy of this message
I need some input from others here, especially from Windows (2000) users. I've been in touch with user, and it seems that fopen fails on URLs that end with a file, so that http://www.mysite.com/index.html fails, while http://www.mysite.com/ works. The first one worked in 4.0.2 but not in 4.0.3. I think the problem might be with the new regexp in url.c, here's the diff: @@ -116,8 +116,8 @@ regfree(&re); /* free the old regex */ - if ((cerr=regcomp(&re, "^(([^@:]+)(:([^@:]+))?@)?([^:@]+)(:([^:@]+))?", REG_EXTENDED)) - || (err=regexec(&re, result, 10, subs, 0))) { + if ((cerr=regcomp(&re, "^(([^@:]+)(:([^@:]+))?@)?((\\[(.*)\\])|([^:@]+))(:([^:@]+))?", REG_EXTENDED)) + || (err=regexec(&re, result, 11, subs, 0))) { STR_FREE(ret->scheme); STR_FREE(ret->path); STR_FREE(ret->query); @@ -135,11 +135,13 @@ if (subs[4].rm_so != -1 && subs[4].rm_so < length) { ret->pass = estrndup(result + subs[4].rm_so, subs[4].rm_eo - subs[4].rm_so); } - if (subs[5].rm_so != -1 && subs[5].rm_so < length) { - ret->host = estrndup(result + subs[5].rm_so, subs[5].rm_eo - subs[5].rm_so); - } if (subs[7].rm_so != -1 && subs[7].rm_so < length) { - ret->port = (unsigned short) strtol(result + subs[7].rm_so, NULL, 10); + ret->host = estrndup(result + subs[7].rm_so, subs[7].rm_eo - subs[7].rm_so); + } else if (subs[8].rm_so != -1 && subs[8].rm_so < length) { + ret->host = estrndup(result + subs[8].rm_so, subs[8].rm_eo - subs[8].rm_so); + } + if (subs[10].rm_so != -1 && subs[10].rm_so < length) { + ret->port = (unsigned short) strtol(result + subs[10].rm_so, NULL, 10); } efree(result); } The code seems to work for most people, but could there be a problem with this on Windows 2000 Server, Service Pack one? This was tested with the binaries at php.net. Anyone else with the same release or at least with Windows have any experiences? I first suspected getaddrinfo problems, but getaddrinfo should of course never be affected by what's in the URL behind the hostport part. Stig

« previous php.dev (#42989) next »