Skip to content

ext/uri: Fixes empty url credentials - #23816

Open
NickSdot wants to merge 3 commits into
php:PHP-8.6from
NickSdot:fix/uri-builder-empty-credentials
Open

NickSdot wants to merge 3 commits into
php:PHP-8.6from
NickSdot:fix/uri-builder-empty-credentials

Conversation

@NickSdot

Copy link
Copy Markdown
Contributor

No description provided.

@NickSdot
NickSdot force-pushed the fix/uri-builder-empty-credentials branch from 366dd11 to 98fe5c5 Compare September 21, 2026 11:00
@NickSdot
NickSdot marked this pull request as ready for review September 22, 2026 01:55
Comment thread ext/uri/uri_parser_whatwg.c Outdated

static const size_t lexbor_mraw_byte_size = 8192;

ZEND_ATTRIBUTE_NONNULL static zend_always_inline bool zval_string_or_null_is_non_empty(const zval *value)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think in this case it doesn't matter if value can be null or not:

Suggested change
ZEND_ATTRIBUTE_NONNULL static zend_always_inline bool zval_string_or_null_is_non_empty(const zval *value)
ZEND_ATTRIBUTE_NONNULL static zend_always_inline bool zval_string_is_non_empty(const zval *value)

But I'm not really sure that this needs to be extracted at all. This code is trivial; what's not trivial is when the non-empty check should be used: in case of the username and port setters which remove the component in question in case of an empty input.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed.

@@ -0,0 +1,50 @@
--TEST--
Test Uri\WhatWg\UrlBuilder::setPassword() - success - empty string with empty host and file base URL

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

apparently there are way too many file tests. is it really needed to have all?

and I miss two tests:

$base = new Uri\WhatWg\Url('https://user:pass@example.com/path');

echo new Uri\WhatWg\Url('', $base)->toAsciiString();
// https://user:pass@example.com/path
$base = new Uri\WhatWg\Url('https://user:pass@example.com/path');

echo $base->withPassword('')->toAsciiString();
// https://user@example.com/path

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added, and removed.

@kocsismate
kocsismate changed the base branch from master to PHP-8.6 September 24, 2026 20:33
@NickSdot

Copy link
Copy Markdown
Contributor Author

Failures unrelated.

@NickSdot
NickSdot requested a review from kocsismate September 30, 2026 09:17
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.

2 participants