-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Add internal URI handling API #19073
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some first remarks. Did not yet look at everything.
static zend_string *parse_url_uri_to_string(void *uri, uri_recomposition_mode_t recomposition_mode, bool exclude_fragment) | ||
{ | ||
ZEND_UNREACHABLE(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be better to simply NULL
the pointer in the uri_handler_t
struct instead.
static void *parse_url_clone_uri(void *uri) | ||
{ | ||
ZEND_UNREACHABLE(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto
zval exception; | ||
|
||
object_init_ex(&exception, uri_invalid_uri_exception_ce); | ||
|
||
zval value; | ||
ZVAL_STRING(&value, "URL parsing failed"); | ||
zend_update_property_ex(uri_whatwg_invalid_url_exception_ce, Z_OBJ(exception), ZSTR_KNOWN(ZEND_STR_MESSAGE), &value); | ||
zval_ptr_dtor_str(&value); | ||
|
||
zend_throw_exception_object(&exception); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be simplified according to the other implementations.
|
||
static zend_result parse_url_read_fragment(const uri_internal_t *internal_uri, uri_component_read_mode_t read_mode, zval *retval) | ||
{ | ||
php_url *parse_url_uri = (php_url *) internal_uri->uri; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Useless cast from void*.
if (uri_handler_name == NULL) { | ||
return uri_handler_by_name("parse_url", sizeof("parse_url") - 1); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Defaulting to parse_url
in a new API is probably not a good idea. Instead the “legacy” users should just pass "parse_url"
explicitly.
return NULL; | ||
} | ||
|
||
uri_internal_t *internal_uri = emalloc(sizeof(uri_internal_t)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uri_internal_t *internal_uri = emalloc(sizeof(uri_internal_t)); | |
uri_internal_t *internal_uri = emalloc(sizeof(*internal_uri)); |
return NULL; | ||
} | ||
|
||
php_uri *uri = ecalloc(1, sizeof(php_uri)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
php_uri *uri = ecalloc(1, sizeof(php_uri)); | |
php_uri *uri = ecalloc(1, sizeof(*uri)); |
No description provided.