1
0
mirror of https://github.com/php/php-src.git synced 2026-04-23 16:08:35 +02:00

10 Commits

Author SHA1 Message Date
Ben Ramsey 113d1acdf0 license-update: ext/uri source headers
RFC: https://wiki.php.net/rfc/php_license_update
2026-04-11 21:20:54 -05:00
Tim Düsterhus 04f06e8cf2 zend_portability: Remove EMPTY_SWITCH_DEFAULT_CASE() (#20063)
There are several issues with this macro:

- It is incorrectly named: It's not an empty default case. It's an unreachable
  default case.
- It is hiding control flow in its definition, which can be confusing for
  humans and tools (such as Coccinelle) alike, because it looks like it would
  be a statement that belongs to the "current" case rather than opening a new
  one.

Since this macro is exactly as long as explicitly spelling out its definition
(excluding the useless `break;`), it is not even making the code any more
succinct.
2026-04-06 14:46:15 +02:00
Tim Düsterhus 79a5804b6b uri: Make php_uri_parser structs PHPAPI (#20243)
This allows extensions that already know which parser to use and don't need the
generic lookup facility to directly refer to the desired parser without needing
to go through `php_uri_get_parser()` (which also requires allocating a
`zend_string*`).

Following php/php-src#20173
Related to php/php-src#19868
2025-10-21 16:09:16 +02:00
Tim Düsterhus e23c6222da uri: Clean up naming of remaining public symbols (#19917)
* uri: Rename `uri_object_t` to `php_uri_object`

* uri: Rename `uri_(read|write)_component_*` to `php_uri_property_(read|write)_*_helper`

* uri: Rename `URI_SERIALIZED_PROPERTY_NAME` to `PHP_URI_SERIALIZE_URI_FIELD_NAME`

* uri: Rename `uri_internal_t` to `php_uri_internal`

* uri: Use proper `php_uri_ce_` prefix for all CEs

* uri: Make the object handlers `static` and remove them from the header
2025-09-23 09:19:56 +02:00
Jakub Zelenka 2b637dfc4e Rename php_uri_parser free to destroy (#19888)
This is to fix Windows debug build when it is macro for _free_dbg
2025-09-19 20:12:35 +02:00
Tim Düsterhus 04deb4df62 uri: Do not pass uri_internal_t to property handlers (#19805)
* uri: Do not pass `uri_internal_t` to property handlers

Within an individual property handler, the `parser` is already implicitly
known, which just leaves the `->uri` field which must contain the entire state
necessary for the handlers to work with.

Pass the `->uri` directly. It avoids one pointer indirection, since the
handlers do not need to follow the pointer to the `uri_internal_t` just to
follow the pointer to the URI state.  Instead the URI pointer can directly be
passed using a register with the dereferences (if necessary) happening in the
caller, providing more insight for the compiler to work with.

It also makes it more convenient to use the handlers directly for code that
already knows that it needs a specific URI parser, since no `uri_internal_t`
needs to be constructed to store the already-known information about which
parser to use.

* uri: Use local variable for the URI in `uri_get_debug_properties()`

This makes the code a little less verbose.
2025-09-11 21:58:03 +02:00
Tim Düsterhus 26eac7de17 uri: Clean up naming of public symbols (#19794)
* uri: Rename `uri_recomposition_mode_t` to `php_uri_recomposition_mode`

* uri: Align the names of the `php_uri_recomposition_mode` values

* uri: Rename `uri_component_read_mode_t` to `php_uri_component_read_mode`

* uri: Align the names of the `php_uri_component_read_mode` values

* uri: Rename `uri_property_name_t` to `php_uri_property_name`

* uri: Align the names of the `php_uri_property_name` values

* uri: Rename `uri_property_handler_t` to `php_uri_property_handler`

* uri: Rename `uri_(read|write)_t` to `php_uri_property_handler_(read|write)`

* uri: Rename `php_uri_property_handler`’s `(read|write)_func` to `read|write`

The `_func` is implied by the data type and the name of the struct.

* uri: Rename `uri_parser_t` to `php_uri_parser`

* uri: Shorten the names of `php_uri_parser` fields

The `_uri` suffix is implied, because this is an URI parser.
2025-09-11 12:10:41 +02:00
Tim Düsterhus 4c04ff33c9 uri: Make the .free_uri handlers safe to call with NULL (#19627)
* uri: Make the `.free_uri` handlers safe to call with `NULL`

The `php_uri_free()` function already unconditionally called `->free_uri()` and
thus couldn't be safely used when the `->uri` was `NULL` for some reason.

The lexbor implementation was already safe, because `lxb_url_destroy()` is
guaranteed to be a noop for `NULL`.

* uri: Stop checking for `NULL` before calling `->free_uri()`

This implicitly fixes an `UNEXPECTED(…->uri != NULL)` in `uri_free_obj_handler`
that likely should have read `EXPECTED` instead.

* uri: Remove unnecessary reset of `->uri` to `NULL` in `php_uri_object_handler_free()`

* uri: Document the requirement of `free_uri()` being safe with `NULL`
2025-09-09 08:37:51 +02:00
Tim Düsterhus e99f1b4fcc uri: Fix normalization memory management for uri_parser_php_parse_url.c (#19600)
There were two issues with the previous implementation of normalization:

- `php_raw_url_decode_ex()` would be used to modify a string with RC >1.
- The return value of `php_raw_url_decode_ex()` was not used, resulting in
  incorrect string lengths when percent-encoded characters are decoded.

Additionally there was a bogus assertion that verified that strings returned
from the read handlers are RC =2, which was not the case for the
`parse_url`-based parser when repeatedly retrieving a component even without
normalization happening. Remove that assertion, since its usefulness is
questionable. Any obvious data type issues with read handlers should be
detectable when testing during development.
2025-08-26 23:44:36 +02:00
Tim Düsterhus ae1438b5e5 uri/standard: Move the parse_url() URI parser into ext/uri/ (#19587)
* uri/standard: Move the `parse_url()` URI parser into ext/uri/

Making ext/standard depend on ext/uri/ is a bit iffy (given that it is called
*standard*) and having the parser implementation in ext/uri/ makes it easier to
find and keep in sync.

* uri: Mark local pointers as `const` in uri_parser_php_parse_url.c

* uri: Remove useless explicit cast from void in uri_parser_php_parse_url.c

* uri: Properly prefix symbols in uri_parser_php_parse_url.[ch]

* uri: Remove useless `throw_invalid_uri_exception()` helper in uri_parser_php_parse_url.c
2025-08-26 14:49:42 +02:00