Skip to content

Conversation

TimWolla
Copy link
Member

This is currently leaking due to uriparser/uriparser#250, thus leaving on draft for now.

@TimWolla TimWolla force-pushed the uri-rfc3986-empty-port branch from 258c8f7 to 5c41900 Compare September 5, 2025 09:08
@TimWolla TimWolla marked this pull request as ready for review September 5, 2025 09:08
@TimWolla TimWolla requested a review from kocsismate as a code owner September 5, 2025 09:08
@TimWolla TimWolla requested review from nielsdos and removed request for kocsismate September 5, 2025 09:08
Copy link
Member

@nielsdos nielsdos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TimWolla
Copy link
Member Author

TimWolla commented Sep 5, 2025

Change looks fine, but doesn't this also need the check:

Yesn't. http://example:/ with an empty port is a valid URI and to my reading of RFC 3986#3.2.3 equivalent to a missing port. The port number 0 is also a valid port number.

The validation in the constructor treats the empty port as 0 (and thus accepts it, since 0 is a valid port). Of course, the check for a valid port could also be skipped entirely there for the empty port and that might indeed be clearer, but from a purely technical perspective, the current implementation is fine.

@TimWolla TimWolla requested a review from nielsdos September 5, 2025 18:55
zend_throw_exception(uri_invalid_uri_exception_ce, "The port is out of range", 0);
}
if (has_text_range(&uri.portText) && get_text_range_length(&uri.portText) > 0) {
if (port_str_to_zend_long_checked(uri.portText.first, get_text_range_length(&uri.portText)) == -1) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: why is the separate if? It seems a bit off

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The outer if is “checking if we have a port” and the inner if is “checking if the port is valid”. Two separate concerns, thus two separate if()s.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find it strange because we are not interested in the former concern, only the latter is needed. But I don't mind the extra indentation too much to bother with this formatting nuance :)

@TimWolla TimWolla merged commit 96c4d8b into php:master Sep 5, 2025
9 checks passed
@TimWolla TimWolla deleted the uri-rfc3986-empty-port branch September 5, 2025 20:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants