Skip to content

Commit 7667f8e

Browse files
committed
Fixed bug #68638 (pg_update() fails to store infinite values)
1 parent 40a9459 commit 7667f8e

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ PHP NEWS
1414
. Fix bug #61285, #68329, #68046, #41631: encrypted streams don't observe
1515
socket timeouts (Brad Broerman)
1616

17+
- pgsql:
18+
. Fixed bug #68638 (pg_update() fails to store infinite values).
19+
(william dot welter at 4linux dot com dot br, Laruence)
20+
1721
- CGI:
1822
. Fixed bug #69015 (php-cgi's getopt does not see $argv). (Laruence)
1923

ext/pgsql/pgsql.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5357,9 +5357,6 @@ static int php_pgsql_convert_match(const char *str, size_t str_len, const char *
53575357

53585358
regerr = regexec(&re, str, re.re_nsub+1, subs, 0);
53595359
if (regerr == REG_NOMATCH) {
5360-
#ifdef PHP_DEBUG
5361-
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "'%s' does not match with '%s'", str, regex);
5362-
#endif
53635360
ret = FAILURE;
53645361
}
53655362
else if (regerr) {
@@ -5607,14 +5604,16 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con
56075604
}
56085605
else {
56095606
/* FIXME: better regex must be used */
5610-
if (php_pgsql_convert_match(Z_STRVAL_PP(val), Z_STRLEN_PP(val), "^([+-]{0,1}[0-9]+)|([+-]{0,1}[0-9]*[\\.][0-9]+)|([+-]{0,1}[0-9]+[\\.][0-9]*)|([+-]{0,1}(inf)(inity){0,1})$", 1 TSRMLS_CC) == FAILURE) {
5611-
err = 1;
5607+
if (php_pgsql_convert_match(Z_STRVAL_PP(val), Z_STRLEN_PP(val), "^([+-]{0,1}[0-9]+)|([+-]{0,1}[0-9]*[\\.][0-9]+)|([+-]{0,1}[0-9]+[\\.][0-9]*)$", 0 TSRMLS_CC) == FAILURE) {
5608+
if (php_pgsql_convert_match(Z_STRVAL_PP(val), Z_STRLEN_PP(val), "^[+-]{0,1}(inf)(inity){0,1}$", 1 TSRMLS_CC) == FAILURE) {
5609+
err = 1;
5610+
} else {
5611+
ZVAL_STRING(new_val, Z_STRVAL_PP(val), 1);
5612+
php_pgsql_add_quotes(new_val, 1 TSRMLS_CC);
5613+
}
56125614
}
56135615
else {
56145616
ZVAL_STRING(new_val, Z_STRVAL_PP(val), 1);
5615-
if(strcasestr(Z_STRVAL_PP(val),"inf")!=0){
5616-
php_pgsql_add_quotes(new_val, 1 TSRMLS_CC);
5617-
}
56185617
}
56195618
}
56205619
break;

0 commit comments

Comments
 (0)