Skip to content

standard: various nit and refactorings for standard stream wrappers - #22875

Open
Girgias wants to merge 4 commits into
php:masterfrom
Girgias:2026-07-std-stream-wrapper-nits
Open

standard: various nit and refactorings for standard stream wrappers#22875
Girgias wants to merge 4 commits into
php:masterfrom
Girgias:2026-07-std-stream-wrapper-nits

Conversation

@Girgias

@Girgias Girgias commented Jul 23, 2026

Copy link
Copy Markdown
Member

No description provided.

@Girgias
Girgias marked this pull request as ready for review July 25, 2026 10:36
@Girgias
Girgias requested a review from bukka as a code owner July 25, 2026 10:36
@Girgias
Girgias requested a review from devnexen July 28, 2026 08:39
}
/* check for control characters in login, password & path */
if (strncasecmp(new_path, "http://", sizeof("http://") - 1) || strncasecmp(new_path, "https://", sizeof("https://") - 1)) {
if (zend_string_starts_with_literal_ci(new_path, "http://") || zend_string_starts_with_literal_ci(new_path, "https://")) {

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.

it seems the old condition was always true regardless ? I would either drop the "migrated" version of it or

if (!zend_string_starts_with_literal_ci(new_path, "http://") && !zend_string_starts_with_literal_ci(new_path, "https://"))
```. wdyt ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'm... not even sure what the semantics are. Reading the rest of the code it does seem to me that it expects the path to start with an HTTP protocol schema....

As we are passing new_path to php_stream_url_wrap_http_ex

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.

No you re right.

Comment thread ext/standard/http_fopen_wrapper.c Outdated
@devnexen

Copy link
Copy Markdown
Member

Seems your PR resolves a relative Location (e.g. Location: baz on /foo/bar) to /foo/baz instead of master's /foo//baz, because it no longer inserts a / separator after a path prefix that already ends in one.

@Girgias

Girgias commented Jul 29, 2026

Copy link
Copy Markdown
Member Author

Seems your PR resolves a relative Location (e.g. Location: baz on /foo/bar) to /foo/baz instead of master's /foo//baz, because it no longer inserts a / separator after a path prefix that already ends in one.

So I guess this PR fixes another pre-existing bug as well, and clearly this part of the stream wrapper is barely used and badly tested :/

- Use newer zend_string APIs
- Make logic more explicit and understandable
- Prevent some strlen() recomputations
@Girgias
Girgias force-pushed the 2026-07-std-stream-wrapper-nits branch from 88c225c to 766bdd8 Compare July 29, 2026 08:50
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