[php-src] Issue #7890: parse_url() and incorrect port definition

From: Date: Thu, 06 Jan 2022 23:21:41 +0000
Subject: [php-src] Issue #7890: parse_url() and incorrect port definition
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-238830@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/7890 Comment Author: cmb69 > As for this specific url: it is technically valid as a relative url, so if parse_url can parse > relative paths, should also parse that url. The problem is the way [php_url_parse_ex2()](https://github.com/php/php-src/blob/php-8.1.1/ext/standard/url.c#L102-L328) is implemented; it is not a proper parser, but rather does some guesswork (which is supposed to work for absolute URLs, but may fail badly for others). In this case it looks for the first : and checks whether this is preceeded by a valid scheme. Obviously, this is not the case, so it checks whether the following characters form a valid port, what is the case. Now try to fix that without breaking existing code which may even [rely on parsing invalid URLs](https://github.com/php/php-src/commit/5174de7cd33c3d4fa591c9c93859ff9989b07e8c#commitcomment-45967652). Best of luck! :) So, in my opinion, parse_url() is beyond repair and needs to be replaced by some sane URI parser (adhering to whatever specification). I'm aware that I sound like a broken record.

« previous php.bugs (#238830) next »