@@ -4456,7 +4456,7 @@ static php_pgsql_data_type php_pgsql_get_data_type(const zend_string *type_name)
4456
4456
/* {{{ php_pgsql_convert_match
4457
4457
* test field value with regular expression specified.
4458
4458
*/
4459
- static int php_pgsql_convert_match (const char * str , size_t str_len , const char * regex , size_t regex_len , int icase )
4459
+ static int php_pgsql_convert_match (const zend_string * str , const char * regex , size_t regex_len , int icase )
4460
4460
{
4461
4461
pcre2_code * re ;
4462
4462
PCRE2_SIZE err_offset ;
@@ -4466,10 +4466,10 @@ static int php_pgsql_convert_match(const char *str, size_t str_len, const char *
4466
4466
pcre2_match_data * match_data ;
4467
4467
4468
4468
/* Check invalid chars for POSIX regex */
4469
- for (i = 0 ; i < str_len ; i ++ ) {
4470
- if (str [i ] == '\n' ||
4471
- str [i ] == '\r' ||
4472
- str [i ] == '\0' ) {
4469
+ for (i = 0 ; i < ZSTR_LEN ( str ) ; i ++ ) {
4470
+ if (ZSTR_VAL ( str ) [i ] == '\n' ||
4471
+ ZSTR_VAL ( str ) [i ] == '\r' ||
4472
+ ZSTR_VAL ( str ) [i ] == '\0' ) {
4473
4473
return FAILURE ;
4474
4474
}
4475
4475
}
@@ -4492,7 +4492,7 @@ static int php_pgsql_convert_match(const char *str, size_t str_len, const char *
4492
4492
php_error_docref (NULL , E_WARNING , "Cannot allocate match data" );
4493
4493
return FAILURE ;
4494
4494
}
4495
- res = pcre2_match (re , (PCRE2_SPTR )str , str_len , 0 , 0 , match_data , php_pcre_mctx ());
4495
+ res = pcre2_match (re , (PCRE2_SPTR )ZSTR_VAL ( str ), ZSTR_LEN ( str ) , 0 , 0 , match_data , php_pcre_mctx ());
4496
4496
php_pcre_free_match_data (match_data );
4497
4497
pcre2_code_free (re );
4498
4498
@@ -4692,7 +4692,7 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con
4692
4692
else {
4693
4693
/* FIXME: better regex must be used */
4694
4694
#define REGEX0 "^([+-]{0,1}[0-9]+)$"
4695
- if (php_pgsql_convert_match (Z_STRVAL_P ( val ), Z_STRLEN_P (val ), REGEX0 , sizeof (REGEX0 )- 1 , 0 ) == FAILURE ) {
4695
+ if (php_pgsql_convert_match (Z_STR_P (val ), REGEX0 , sizeof (REGEX0 )- 1 , 0 ) == FAILURE ) {
4696
4696
err = 1 ;
4697
4697
}
4698
4698
else {
@@ -4737,8 +4737,8 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con
4737
4737
#define REGEX0 "^[-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?$"
4738
4738
#define REGEX1 "^[+-]{0,1}(inf)(inity){0,1}$"
4739
4739
/* better regex? */
4740
- if (php_pgsql_convert_match (Z_STRVAL_P ( val ), Z_STRLEN_P (val ), REGEX0 , sizeof (REGEX0 )- 1 , 0 ) == FAILURE ) {
4741
- if (php_pgsql_convert_match (Z_STRVAL_P ( val ), Z_STRLEN_P (val ), REGEX1 , sizeof (REGEX1 )- 1 , 1 ) == FAILURE ) {
4740
+ if (php_pgsql_convert_match (Z_STR_P (val ), REGEX0 , sizeof (REGEX0 )- 1 , 0 ) == FAILURE ) {
4741
+ if (php_pgsql_convert_match (Z_STR_P (val ), REGEX1 , sizeof (REGEX1 )- 1 , 1 ) == FAILURE ) {
4742
4742
err = 1 ;
4743
4743
} else {
4744
4744
ZVAL_STRING (& new_val , Z_STRVAL_P (val ));
@@ -4846,7 +4846,7 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con
4846
4846
}
4847
4847
else {
4848
4848
/* better regex? */
4849
- if (php_pgsql_convert_match (Z_STRVAL_P ( val ), Z_STRLEN_P (val ), "^[0-9]+$" , sizeof ("^[0-9]+$" )- 1 , 0 ) == FAILURE ) {
4849
+ if (php_pgsql_convert_match (Z_STR_P (val ), "^[0-9]+$" , sizeof ("^[0-9]+$" )- 1 , 0 ) == FAILURE ) {
4850
4850
err = 1 ;
4851
4851
}
4852
4852
else {
@@ -4891,8 +4891,8 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con
4891
4891
/* The inet type holds an IPv4 or IPv6 host address, and optionally its subnet, all in one field. See more in the doc.
4892
4892
The regex might still be not perfect, but catches the most of IP variants. We might decide to remove the regex
4893
4893
at all though and let the server side to handle it.*/
4894
- if (php_pgsql_convert_match (Z_STRVAL_P ( val ), Z_STRLEN_P (val ), REGEX0 , sizeof (REGEX0 )- 1 , 0 ) == FAILURE
4895
- && php_pgsql_convert_match (Z_STRVAL_P ( val ), Z_STRLEN_P (val ), REGEX1 , sizeof (REGEX1 )- 1 , 0 ) == FAILURE ) {
4894
+ if (php_pgsql_convert_match (Z_STR_P (val ), REGEX0 , sizeof (REGEX0 )- 1 , 0 ) == FAILURE
4895
+ && php_pgsql_convert_match (Z_STR_P (val ), REGEX1 , sizeof (REGEX1 )- 1 , 0 ) == FAILURE ) {
4896
4896
err = 1 ;
4897
4897
}
4898
4898
else {
@@ -4929,7 +4929,7 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con
4929
4929
} else {
4930
4930
#define REGEX0 "^([0-9]{4}[/-][0-9]{1,2}[/-][0-9]{1,2})(([ \\t]+|T)(([0-9]{1,2}:[0-9]{1,2}){1}(:[0-9]{1,2}){0,1}(\\.[0-9]+){0,1}([ \\t]*([+-][0-9]{1,4}(:[0-9]{1,2}){0,1}|[-a-zA-Z_/+]{1,50})){0,1})){0,1}$"
4931
4931
/* better regex? */
4932
- if (php_pgsql_convert_match (Z_STRVAL_P ( val ), Z_STRLEN_P (val ), REGEX0 , sizeof (REGEX0 )- 1 , 1 ) == FAILURE ) {
4932
+ if (php_pgsql_convert_match (Z_STR_P (val ), REGEX0 , sizeof (REGEX0 )- 1 , 1 ) == FAILURE ) {
4933
4933
err = 1 ;
4934
4934
} else {
4935
4935
ZVAL_STRING (& new_val , Z_STRVAL_P (val ));
@@ -4961,7 +4961,7 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con
4961
4961
else {
4962
4962
#define REGEX0 "^([0-9]{4}[/-][0-9]{1,2}[/-][0-9]{1,2})$"
4963
4963
/* FIXME: better regex must be used */
4964
- if (php_pgsql_convert_match (Z_STRVAL_P ( val ), Z_STRLEN_P (val ), REGEX0 , sizeof (REGEX0 )- 1 , 1 ) == FAILURE ) {
4964
+ if (php_pgsql_convert_match (Z_STR_P (val ), REGEX0 , sizeof (REGEX0 )- 1 , 1 ) == FAILURE ) {
4965
4965
err = 1 ;
4966
4966
}
4967
4967
else {
@@ -4994,7 +4994,7 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con
4994
4994
else {
4995
4995
#define REGEX0 "^(([0-9]{1,2}:[0-9]{1,2}){1}(:[0-9]{1,2}){0,1}){0,1}$"
4996
4996
/* FIXME: better regex must be used */
4997
- if (php_pgsql_convert_match (Z_STRVAL_P ( val ), Z_STRLEN_P (val ), REGEX0 , sizeof (REGEX0 )- 1 , 1 ) == FAILURE ) {
4997
+ if (php_pgsql_convert_match (Z_STR_P (val ), REGEX0 , sizeof (REGEX0 )- 1 , 1 ) == FAILURE ) {
4998
4998
err = 1 ;
4999
4999
}
5000
5000
else {
@@ -5073,7 +5073,7 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con
5073
5073
")?))" \
5074
5074
"([ \\t]+ago)?$"
5075
5075
5076
- if (php_pgsql_convert_match (Z_STRVAL_P ( val ), Z_STRLEN_P (val ), REGEX0 , sizeof (REGEX0 )- 1 , 1 ) == FAILURE ) {
5076
+ if (php_pgsql_convert_match (Z_STR_P (val ), REGEX0 , sizeof (REGEX0 )- 1 , 1 ) == FAILURE ) {
5077
5077
err = 1 ;
5078
5078
}
5079
5079
else {
@@ -5147,7 +5147,7 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con
5147
5147
}
5148
5148
else {
5149
5149
#define REGEX0 "^([0-9a-f]{2,2}:){5,5}[0-9a-f]{2,2}$"
5150
- if (php_pgsql_convert_match (Z_STRVAL_P ( val ), Z_STRLEN_P (val ), REGEX0 , sizeof (REGEX0 )- 1 , 1 ) == FAILURE ) {
5150
+ if (php_pgsql_convert_match (Z_STR_P (val ), REGEX0 , sizeof (REGEX0 )- 1 , 1 ) == FAILURE ) {
5151
5151
err = 1 ;
5152
5152
}
5153
5153
else {
0 commit comments