summaryrefslogtreecommitdiff
path: root/ext/standard/string.c
diff options
context:
space:
mode:
authorYasuo Ohgaki <yohgaki@php.net>2002-03-12 07:05:40 +0000
committerYasuo Ohgaki <yohgaki@php.net>2002-03-12 07:05:40 +0000
commitc43792602e8c6549adecfb5e59702cbb63cd9807 (patch)
tree07f061637451438dde2cd7f8d881886a1241a4fe /ext/standard/string.c
parente953dba0d73e1ec6aa5d2fc97f343eb7eb6ca5bb (diff)
downloadphp-git-c43792602e8c6549adecfb5e59702cbb63cd9807.tar.gz
Change php_addslashes() a little.
Since most users do not use magic_quote_sybase, be nicer to users not using magic_quote_sybase.
Diffstat (limited to 'ext/standard/string.c')
-rw-r--r--ext/standard/string.c50
1 files changed, 31 insertions, 19 deletions
diff --git a/ext/standard/string.c b/ext/standard/string.c
index dad7f5c03b..e255dc09b5 100644
--- a/ext/standard/string.c
+++ b/ext/standard/string.c
@@ -2396,29 +2396,41 @@ PHPAPI char *php_addslashes(char *str, int length, int *new_length, int should_f
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;