Re: cvs: php4(PHP_4_2_0) /ext/pgsql pgsql.c /ext/pgsql/tests 08escape.phpt escape.inc

From: Date: Thu, 04 Apr 2002 22:26:07 +0000
Subject: Re: cvs: php4(PHP_4_2_0) /ext/pgsql pgsql.c /ext/pgsql/tests 08escape.phpt escape.inc
References: 1  Groups: php.cvs php.qa 
Request: Send a blank email to php-cvs+get-10878@lists.php.net to get a copy of this message
derick@php.net wrote:
Hello Yasuo, although I dont oppose merging this fix, you should have discussed it first. We're in the last stadion of RC now, and we certainly dont want weird/stray patches go in now. Derick
Oh. Sorry. I mentioned it in HEAD comment, but delay wasn't long enough. I'll directly mail you. -- Yasuo Ohgaki
On Thu, 4 Apr 2002, Yasuo Ohgaki wrote:
yohgaki Thu Apr 4 10:29:35 2002 EDT
 Added files:                 (Branch: PHP_4_2_0)
   /php4/ext/pgsql/tests	08escape.phpt escape.inc 
 Modified files:                 /php4/ext/pgsql	pgsql.c  Log:
MFH # Fixed crash with pg_escape_*() # Added test for pg_escape_*() Index: php4/ext/pgsql/pgsql.c diff -u php4/ext/pgsql/pgsql.c:1.150.2.3 php4/ext/pgsql/pgsql.c:1.150.2.4 --- php4/ext/pgsql/pgsql.c:1.150.2.3 Sat Mar 30 18:23:58 2002 +++ php4/ext/pgsql/pgsql.c Thu Apr 4 10:29:34 2002 @@ -19,7 +19,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: pgsql.c,v 1.150.2.3 2002/03/30 23:23:58 yohgaki Exp $ */ +/* $Id: pgsql.c,v 1.150.2.4 2002/04/04 15:29:34 yohgaki Exp $ */ #include <stdlib.h> @@ -2376,17 +2376,15 @@ PHP_FUNCTION(pg_escape_string) { char *from = NULL, *to = NULL; - int len; + size_t from_len, to_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", - &from, &len) == FAILURE) { + &from, &from_len) == FAILURE) { return; } - len = (int)PQescapeString(to, from, strlen(from)); - if (len < 0) { - RETURN_FALSE; - } - RETURN_STRINGL(to, len, 0); + to = (char *)emalloc(from_len*2+1); + to_len = (int)PQescapeString(to, from, from_len); + RETURN_STRINGL(to, to_len, 0); } /* }}} */ @@ -2395,17 +2393,15 @@ PHP_FUNCTION(pg_escape_bytea) { char *from = NULL, *to = NULL; - int len; + size_t from_len, to_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", - &from, &len) == FAILURE) { + &from, &from_len) == FAILURE) { return; } - to = (char *)PQescapeBytea((unsigned char*)from, strlen(from), (size_t *)&len); - if (len < 0) { - RETURN_FALSE; - } - RETURN_STRINGL(to, len, 0); + to = (char *)PQescapeBytea((unsigned char*)from, from_len, &to_len); + RETVAL_STRINGL(to, to_len-1, 1); + free(to); } /* }}} */ #endif Index: php4/ext/pgsql/tests/08escape.phpt +++ php4/ext/pgsql/tests/08escape.phpt --TEST-- PostgreSQL escape functions --SKIPIF-- <?php include("skipif.inc"); ?> --FILE-- <?php include("escape.inc"); ?> --EXPECT-- OK Index: php4/ext/pgsql/tests/escape.inc +++ php4/ext/pgsql/tests/escape.inc <?php $before = "ABC\\ABC"; $expect = "ABC\\\\ABC"; $after = pg_escape_string($before); if ($expect === $after) { echo "pg_escpae_string() is Ok\n"; } else { echo "pg_escpae_string() is NOT Ok\n"; var_dump($before); var_dump($after); var_dump($expect); } $before = "ABC\\ABC"; $expect = "ABC\\\\\\\\ABC"; $after = pg_escape_bytea($before); if ($expect === $after) { echo "pg_escpae_byte() is Ok\n"; } else { echo "pg_escpae_byte() is NOT Ok\n"; var_dump($before); var_dump($after); var_dump($expect); } ?> -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
-----------------------------------------------------------------------
              PHP: Scripting the Web - derick@php.net
                All your branches are belong to me!
            SRM: Script Running Machine - www.vl-srm.net
-----------------------------------------------------------------------


« previous php.cvs (#10878) next »