Skip to content

Commit 748bc87

Browse files
committed
uri: Skip the port validation during parsing when port component is empty
1 parent baf3937 commit 748bc87

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

ext/uri/uri_parser_rfc3986.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -326,15 +326,14 @@ php_uri_parser_rfc3986_uris *php_uri_parser_rfc3986_parse_ex(const char *uri_str
326326
/* Make the resulting URI independent of the 'uri_str'. */
327327
uriMakeOwnerMmA(&uri, mm);
328328

329-
if (
330-
has_text_range(&uri.portText)
331-
&& port_str_to_zend_long_checked(uri.portText.first, get_text_range_length(&uri.portText)) == -1
332-
) {
333-
if (!silent) {
334-
zend_throw_exception(uri_invalid_uri_exception_ce, "The port is out of range", 0);
335-
}
329+
if (has_text_range(&uri.portText) && get_text_range_length(&uri.portText) > 0) {
330+
if (port_str_to_zend_long_checked(uri.portText.first, get_text_range_length(&uri.portText)) == -1) {
331+
if (!silent) {
332+
zend_throw_exception(uri_invalid_uri_exception_ce, "The port is out of range", 0);
333+
}
336334

337-
goto fail;
335+
goto fail;
336+
}
338337
}
339338

340339
php_uri_parser_rfc3986_uris *uriparser_uris = uriparser_create_uris();

0 commit comments

Comments
 (0)