Skip to content

Commit ab30499

Browse files
committed
More review fixes
1 parent ea2778c commit ab30499

File tree

10 files changed

+23
-33
lines changed

10 files changed

+23
-33
lines changed

ext/filter/logical_filters.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -629,10 +629,7 @@ void php_filter_validate_url(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
629629
}
630630

631631
if (
632-
/* @todo Find a better solution than hardcoding the uri handler name. Skipping these checks is needed because
633-
* both uriparser and lexbor performs comprehensive validations. Also, the [] pair is removed by these
634-
* libraries in case of ipv6 URIs, therefore php_filter_is_valid_ipv6_hostname() would case false positive
635-
* failures. */
632+
/* Skipping these checks is possible because the new URI implementations perform comprehensive validations. */
636633
strcmp(uri_handler->name, URI_PARSER_PHP) == 0 &&
637634
/* An IPv6 enclosed by square brackets is a valid hostname.*/
638635
!php_filter_is_valid_ipv6_hostname(uri->host) &&
@@ -654,7 +651,7 @@ void php_filter_validate_url(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
654651
RETURN_VALIDATION_FAILED
655652
}
656653

657-
if (strcmp(uri_handler->name, "parse_url") == 0 &&
654+
if (strcmp(uri_handler->name, URI_PARSER_PHP) == 0 &&
658655
(
659656
(uri->user != NULL && !is_userinfo_valid(uri->user)) ||
660657
(uri->password != NULL && !is_userinfo_valid(uri->password))

ext/openssl/xp_ssl.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
#include "php.h"
2525
#include "ext/standard/file.h"
26-
#include "ext/standard/url.h"
26+
#include "ext/uri/php_uri.h"
2727
#include "streams/php_streams_int.h"
2828
#include "zend_smart_str.h"
2929
#include "php_openssl.h"
@@ -2636,11 +2636,11 @@ static char *php_openssl_get_url_name(const char *resourcename,
26362636
return NULL;
26372637
}
26382638

2639+
char * url_name = NULL;
26392640
zval host_zv;
26402641
zend_result result = php_uri_get_host(internal_uri, URI_COMPONENT_READ_RAW, &host_zv);
26412642
if (result == SUCCESS && Z_TYPE(host_zv) == IS_STRING) {
26422643
const char * host = Z_STRVAL(host_zv);
2643-
char * url_name = NULL;
26442644
size_t len = Z_STRLEN(host_zv);
26452645

26462646
/* skip trailing dots */
@@ -2651,15 +2651,12 @@ static char *php_openssl_get_url_name(const char *resourcename,
26512651
if (len) {
26522652
url_name = pestrndup(host, len, is_persistent);
26532653
}
2654-
2655-
php_uri_free(internal_uri);
2656-
zval_ptr_dtor(&host_zv);
2657-
return url_name;
26582654
}
26592655

26602656
php_uri_free(internal_uri);
26612657
zval_ptr_dtor(&host_zv);
2662-
return NULL;
2658+
2659+
return url_name;
26632660
}
26642661
/* }}} */
26652662

ext/soap/php_http.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -336,14 +336,10 @@ static bool in_domain(const zend_string *host, const zend_string *domain)
336336
}
337337
}
338338

339-
int make_http_soap_request(zval *this_ptr,
340-
zend_string *buf,
341-
zend_string *location,
342-
char *soapaction,
343-
int soap_version,
344-
const zend_string *uri_parser_class,
345-
zval *return_value)
346-
{
339+
int make_http_soap_request(
340+
zval *this_ptr, zend_string *buf, zend_string *location, char *soapaction,
341+
int soap_version, const zend_string *uri_parser_class, zval *return_value
342+
) {
347343
zend_string *request;
348344
smart_str soap_headers = {0};
349345
smart_str soap_headers_z = {0};

ext/soap/php_http.h

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,10 @@
1919
#ifndef PHP_HTTP_H
2020
#define PHP_HTTP_H
2121

22-
int make_http_soap_request(zval *this_ptr,
23-
zend_string *buf,
24-
zend_string *location,
25-
char *soapaction,
26-
int soap_version,
27-
const zend_string *uri_parser_class,
28-
zval *return_value);
22+
int make_http_soap_request(
23+
zval *this_ptr, zend_string *buf, zend_string *location, char *soapaction,
24+
int soap_version, const zend_string *uri_parser_class, zval *return_value
25+
);
2926

3027
int proxy_authentication(zval* this_ptr, smart_str* soap_headers);
3128
int basic_authentication(zval* this_ptr, smart_str* soap_headers);

ext/standard/ftp_fopen_wrapper.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#endif
3939

4040
#include "php_standard.h"
41+
#include "ext/uri/php_uri.h"
4142

4243
#include <sys/types.h>
4344
#ifdef HAVE_SYS_SOCKET_H

ext/standard/http_fopen_wrapper.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
#include "php.h"
2222
#include "php_globals.h"
23+
#include "ext/uri/php_uri.h"
2324
#include "php_streams.h"
2425
#include "php_network.h"
2526
#include "php_ini.h"

ext/uri/php_uri.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,6 @@ ZEND_ATTRIBUTE_NONNULL PHPAPI php_uri *php_uri_parse_to_struct(
197197

198198
php_uri *uri = ecalloc(1, sizeof(*uri));
199199
zval tmp;
200-
ZVAL_UNDEF(&tmp);
201200
zend_result result;
202201

203202
result = php_uri_get_scheme(uri_internal, read_mode, &tmp);

ext/uri/php_uri.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
extern zend_module_entry uri_module_entry;
2323
#define phpext_uri_ptr &uri_module_entry
2424

25-
typedef struct {
25+
typedef struct php_uri {
2626
zend_string *scheme;
2727
zend_string *user;
2828
zend_string *password;

main/streams/php_stream_context.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
+----------------------------------------------------------------------+
1515
*/
1616

17-
#include "ext/uri/php_uri.h"
18-
1917
/* Stream context and status notification related definitions */
2018

2119
/* callback for status notifications */
@@ -67,7 +65,10 @@ PHPAPI void php_stream_context_set_option(php_stream_context *context,
6765
const char *wrappername, const char *optionname, zval *optionvalue);
6866
void php_stream_context_unset_option(php_stream_context *context,
6967
const char *wrappername, const char *optionname);
70-
PHPAPI uri_handler_t *php_stream_context_get_uri_handler(const char *wrappername, php_stream_context *context);
68+
69+
struct uri_handler_t;
70+
71+
PHPAPI struct uri_handler_t *php_stream_context_get_uri_handler(const char *wrappername, php_stream_context *context);
7172
PHPAPI php_stream_notifier *php_stream_notification_alloc(void);
7273
PHPAPI void php_stream_notification_free(php_stream_notifier *notifier);
7374
END_EXTERN_C()

main/streams/streams.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "ext/standard/file.h"
2929
#include "ext/standard/basic_functions.h" /* for BG(CurrentStatFile) */
3030
#include "ext/standard/php_string.h" /* for php_memnstr, used by php_stream_get_record() */
31+
#include "ext/uri/php_uri.h"
3132
#include <stddef.h>
3233
#include <fcntl.h>
3334
#include "php_streams_int.h"
@@ -2457,7 +2458,7 @@ void php_stream_context_unset_option(php_stream_context *context,
24572458
}
24582459
/* }}} */
24592460

2460-
PHPAPI uri_handler_t *php_stream_context_get_uri_handler(const char *wrappername, php_stream_context *context)
2461+
PHPAPI struct uri_handler_t *php_stream_context_get_uri_handler(const char *wrappername, php_stream_context *context)
24612462
{
24622463
if (context == NULL) {
24632464
return php_uri_get_handler(NULL);

0 commit comments

Comments
 (0)