cvs: php4 /ext/standard string.c

From: Date: Tue, 12 Mar 2002 07:05:40 +0000
Subject: cvs: php4 /ext/standard string.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-9935@lists.php.net to get a copy of this message
yohgaki Tue Mar 12 02:05:40 2002 EDT Modified files: /php4/ext/standard string.c Log: Change php_addslashes() a little. Since most users do not use magic_quote_sybase, be nicer to users not using magic_quote_sybase. Index: php4/ext/standard/string.c diff -u php4/ext/standard/string.c:1.263 php4/ext/standard/string.c:1.264 --- php4/ext/standard/string.c:1.263 Sat Mar 2 09:06:57 2002 +++ php4/ext/standard/string.c Tue Mar 12 02:05:40 2002 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: string.c,v 1.263 2002/03/02 14:06:57 derick Exp $ */ +/* $Id: string.c,v 1.264 2002/03/12 07:05:40 yohgaki Exp $ */ /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */ @@ -2396,29 +2396,41 @@ return str; } new_str = (char *) emalloc((length?length:(length=strlen(str)))*2+1); - for (source=str, end=source+length, target=new_str; source<end; source++) { - c = *source; - switch(c) { - case '\0': - *target++ = '\\'; - *target++ = '0'; - break; - case '\'': - if (PG(magic_quotes_sybase)) { + if (PG(magic_quotes_sybase)) { + for (source=str, end=source+length, target=new_str; source<end; source++) { + c = *source; + switch(c) { + case '\0': + *target++ = '\\'; + *target++ = '0'; + break; + case '\'': *target++ = '\''; *target++ = '\''; break; - } - /* break is missing *intentionally* */ - case '\"': - case '\\': - if (!PG(magic_quotes_sybase)) { - *target++ = '\\'; - } - /* break is missing *intentionally* */ - default: - *target++ = c; + default: + *target++ = c; break; + } + } + } + else { + for (source=str, end=source+length, target=new_str; source<end; source++) { + c = *source; + switch(c) { + case '\0': + *target++ = '\\'; + *target++ = '0'; + break; + case '\'': + case '\"': + case '\\': + *target++ = '\\'; + /* break is missing *intentionally* */ + default: + *target++ = c; + break; + } } } *target = 0;

« previous php.cvs (#9935) next »