23
23
#include <arpa/inet.h>
24
24
#endif
25
25
26
- ZEND_TLS lxb_url_parser_t * lexbor_parser ;
26
+ ZEND_TLS lxb_url_parser_t lexbor_parser ;
27
27
ZEND_TLS int lexbor_urls ;
28
28
29
29
#define LEXBOR_MAX_URL_COUNT 500
@@ -45,7 +45,7 @@ static zend_always_inline void zval_long_or_null_to_lexbor_str(zval *value, lexb
45
45
{
46
46
if (Z_TYPE_P (value ) == IS_LONG ) {
47
47
ZVAL_STR (value , zend_long_to_str (Z_LVAL_P (value )));
48
- lexbor_str_init_append (lexbor_str , lexbor_parser -> mraw , (const lxb_char_t * ) Z_STRVAL_P (value ), Z_STRLEN_P (value ));
48
+ lexbor_str_init_append (lexbor_str , lexbor_parser . mraw , (const lxb_char_t * ) Z_STRVAL_P (value ), Z_STRLEN_P (value ));
49
49
zval_ptr_dtor_str (value );
50
50
} else {
51
51
ZEND_ASSERT (Z_ISNULL_P (value ));
@@ -57,10 +57,10 @@ static zend_always_inline void zval_long_or_null_to_lexbor_str(zval *value, lexb
57
57
static void lexbor_cleanup_parser (void )
58
58
{
59
59
if (++ lexbor_urls % LEXBOR_MAX_URL_COUNT == 0 ) {
60
- lexbor_mraw_clean (lexbor_parser -> mraw );
60
+ lexbor_mraw_clean (lexbor_parser . mraw );
61
61
}
62
62
63
- lxb_url_parser_clean (lexbor_parser );
63
+ lxb_url_parser_clean (& lexbor_parser );
64
64
}
65
65
66
66
/**
@@ -81,12 +81,12 @@ static void fill_errors(zval *errors)
81
81
82
82
array_init (errors );
83
83
84
- if (lexbor_parser -> log == NULL ) {
84
+ if (lexbor_parser . log == NULL ) {
85
85
return ;
86
86
}
87
87
88
88
lexbor_plog_entry_t * lxb_error ;
89
- while ((lxb_error = lexbor_array_obj_pop (& lexbor_parser -> log -> list )) != NULL ) {
89
+ while ((lxb_error = lexbor_array_obj_pop (& lexbor_parser . log -> list )) != NULL ) {
90
90
zval error ;
91
91
object_init_ex (& error , uri_whatwg_url_validation_error_ce );
92
92
zend_update_property_string (uri_whatwg_url_validation_error_ce , Z_OBJ (error ), ZEND_STRL ("context" ), (const char * ) lxb_error -> data );
@@ -254,7 +254,7 @@ static zend_result lexbor_write_scheme(struct uri_internal_t *internal_uri, zval
254
254
255
255
zval_string_or_null_to_lexbor_str (value , & str );
256
256
257
- if (lxb_url_api_protocol_set (lexbor_uri , lexbor_parser , str .data , str .length ) != LXB_STATUS_OK ) {
257
+ if (lxb_url_api_protocol_set (lexbor_uri , & lexbor_parser , str .data , str .length ) != LXB_STATUS_OK ) {
258
258
fill_errors (errors );
259
259
260
260
return FAILURE ;
@@ -323,13 +323,13 @@ static zend_result lexbor_write_password(struct uri_internal_t *internal_uri, zv
323
323
324
324
static zend_result init_idna (void )
325
325
{
326
- if (lexbor_parser -> idna != NULL ) {
326
+ if (lexbor_parser . idna != NULL ) {
327
327
return SUCCESS ;
328
328
}
329
329
330
- lexbor_parser -> idna = lxb_unicode_idna_create ();
330
+ lexbor_parser . idna = lxb_unicode_idna_create ();
331
331
332
- return lxb_unicode_idna_init (lexbor_parser -> idna ) == LXB_STATUS_OK ? SUCCESS : FAILURE ;
332
+ return lxb_unicode_idna_init (lexbor_parser . idna ) == LXB_STATUS_OK ? SUCCESS : FAILURE ;
333
333
}
334
334
335
335
static zend_result lexbor_read_host (const struct uri_internal_t * internal_uri , uri_component_read_mode_t read_mode , zval * retval )
@@ -357,8 +357,8 @@ static zend_result lexbor_read_host(const struct uri_internal_t *internal_uri, u
357
357
if (init_idna () == FAILURE ) {
358
358
return FAILURE ;
359
359
}
360
- lxb_url_serialize_host_unicode (lexbor_parser -> idna , & lexbor_uri -> host , lexbor_serialize_callback , & host_str );
361
- lxb_unicode_idna_clean (lexbor_parser -> idna );
360
+ lxb_url_serialize_host_unicode (lexbor_parser . idna , & lexbor_uri -> host , lexbor_serialize_callback , & host_str );
361
+ lxb_unicode_idna_clean (lexbor_parser . idna );
362
362
363
363
ZVAL_NEW_STR (retval , smart_str_extract (& host_str ));
364
364
break ;
@@ -384,7 +384,7 @@ static zend_result lexbor_write_host(struct uri_internal_t *internal_uri, zval *
384
384
385
385
zval_string_or_null_to_lexbor_str (value , & str );
386
386
387
- if (lxb_url_api_hostname_set (lexbor_uri , lexbor_parser , str .data , str .length ) != LXB_STATUS_OK ) {
387
+ if (lxb_url_api_hostname_set (lexbor_uri , & lexbor_parser , str .data , str .length ) != LXB_STATUS_OK ) {
388
388
fill_errors (errors );
389
389
390
390
return FAILURE ;
@@ -413,7 +413,7 @@ static zend_result lexbor_write_port(struct uri_internal_t *internal_uri, zval *
413
413
414
414
zval_long_or_null_to_lexbor_str (value , & str );
415
415
416
- if (lxb_url_api_port_set (lexbor_uri , lexbor_parser , str .data , str .length ) != LXB_STATUS_OK ) {
416
+ if (lxb_url_api_port_set (lexbor_uri , & lexbor_parser , str .data , str .length ) != LXB_STATUS_OK ) {
417
417
fill_errors (errors );
418
418
419
419
return FAILURE ;
@@ -442,7 +442,7 @@ static zend_result lexbor_write_path(struct uri_internal_t *internal_uri, zval *
442
442
443
443
zval_string_or_null_to_lexbor_str (value , & str );
444
444
445
- if (lxb_url_api_pathname_set (lexbor_uri , lexbor_parser , str .data , str .length ) != LXB_STATUS_OK ) {
445
+ if (lxb_url_api_pathname_set (lexbor_uri , & lexbor_parser , str .data , str .length ) != LXB_STATUS_OK ) {
446
446
fill_errors (errors );
447
447
448
448
return FAILURE ;
@@ -471,7 +471,7 @@ static zend_result lexbor_write_query(struct uri_internal_t *internal_uri, zval
471
471
472
472
zval_string_or_null_to_lexbor_str (value , & str );
473
473
474
- if (lxb_url_api_search_set (lexbor_uri , lexbor_parser , str .data , str .length ) != LXB_STATUS_OK ) {
474
+ if (lxb_url_api_search_set (lexbor_uri , & lexbor_parser , str .data , str .length ) != LXB_STATUS_OK ) {
475
475
fill_errors (errors );
476
476
477
477
return FAILURE ;
@@ -500,7 +500,7 @@ static zend_result lexbor_write_fragment(struct uri_internal_t *internal_uri, zv
500
500
501
501
zval_string_or_null_to_lexbor_str (value , & str );
502
502
503
- if (lxb_url_api_hash_set (lexbor_uri , lexbor_parser , str .data , str .length ) != LXB_STATUS_OK ) {
503
+ if (lxb_url_api_hash_set (lexbor_uri , & lexbor_parser , str .data , str .length ) != LXB_STATUS_OK ) {
504
504
fill_errors (errors );
505
505
506
506
return FAILURE ;
@@ -518,11 +518,9 @@ zend_result lexbor_request_init(void)
518
518
return FAILURE ;
519
519
}
520
520
521
- lexbor_parser = lxb_url_parser_create ();
522
- status = lxb_url_parser_init (lexbor_parser , mraw );
521
+ status = lxb_url_parser_init (& lexbor_parser , mraw );
523
522
if (status != LXB_STATUS_OK ) {
524
- lxb_url_parser_destroy (lexbor_parser , true);
525
- lexbor_parser = NULL ;
523
+ lxb_url_parser_destroy (& lexbor_parser , false);
526
524
lexbor_mraw_destroy (mraw , true);
527
525
return FAILURE ;
528
526
}
@@ -534,10 +532,9 @@ zend_result lexbor_request_init(void)
534
532
535
533
void lexbor_request_shutdown (void )
536
534
{
537
- lxb_url_parser_memory_destroy (lexbor_parser );
538
- lxb_url_parser_destroy (lexbor_parser , true );
535
+ lxb_url_parser_memory_destroy (& lexbor_parser );
536
+ lxb_url_parser_destroy (& lexbor_parser , false );
539
537
540
- lexbor_parser = NULL ;
541
538
lexbor_urls = 0 ;
542
539
}
543
540
@@ -546,7 +543,7 @@ static void *lexbor_parse_uri(const zend_string *uri_str, const void *base_url,
546
543
lexbor_cleanup_parser ();
547
544
548
545
const lxb_url_t * lexbor_base_url = base_url ;
549
- lxb_url_t * url = lxb_url_parse (lexbor_parser , lexbor_base_url , (unsigned char * ) ZSTR_VAL (uri_str ), ZSTR_LEN (uri_str ));
546
+ lxb_url_t * url = lxb_url_parse (& lexbor_parser , lexbor_base_url , (unsigned char * ) ZSTR_VAL (uri_str ), ZSTR_LEN (uri_str ));
550
547
fill_errors (errors );
551
548
552
549
return url ;
@@ -570,7 +567,7 @@ static void *lexbor_clone_uri(void *uri)
570
567
{
571
568
lxb_url_t * lexbor_uri = (lxb_url_t * ) uri ;
572
569
573
- return lxb_url_clone (lexbor_parser -> mraw , lexbor_uri );
570
+ return lxb_url_clone (lexbor_parser . mraw , lexbor_uri );
574
571
}
575
572
576
573
static zend_string * lexbor_uri_to_string (void * uri , uri_recomposition_mode_t recomposition_mode , bool exclude_fragment )
@@ -585,8 +582,8 @@ static zend_string *lexbor_uri_to_string(void *uri, uri_recomposition_mode_t rec
585
582
if (init_idna () == FAILURE ) {
586
583
return NULL ;
587
584
}
588
- lxb_url_serialize_idna (lexbor_parser -> idna , lexbor_uri , lexbor_serialize_callback , & uri_str , exclude_fragment );
589
- lxb_unicode_idna_clean (lexbor_parser -> idna );
585
+ lxb_url_serialize_idna (lexbor_parser . idna , lexbor_uri , lexbor_serialize_callback , & uri_str , exclude_fragment );
586
+ lxb_unicode_idna_clean (lexbor_parser . idna );
590
587
break ;
591
588
case URI_RECOMPOSITION_RAW_ASCII :
592
589
ZEND_FALLTHROUGH ;
0 commit comments