diff options
Diffstat (limited to 'ext')
| -rw-r--r-- | ext/bz2/bz2.c | 7 | ||||
| -rw-r--r-- | ext/dba/dba.c | 20 | ||||
| -rw-r--r-- | ext/exif/exif.c | 32 | ||||
| -rw-r--r-- | ext/filter/filter.c | 2 | ||||
| -rw-r--r-- | ext/interbase/ibase_query.c | 7 | ||||
| -rw-r--r-- | ext/mcrypt/mcrypt.c | 2 | ||||
| -rw-r--r-- | ext/mssql/php_mssql.c | 18 | ||||
| -rw-r--r-- | ext/mysql/php_mysql.c | 8 | ||||
| -rw-r--r-- | ext/mysqli/mysqli.c | 4 | ||||
| -rw-r--r-- | ext/pcre/php_pcre.c | 2 | ||||
| -rw-r--r-- | ext/pdo/tests/pdo_test.inc | 3 | ||||
| -rw-r--r-- | ext/pgsql/pgsql.c | 17 | ||||
| -rw-r--r-- | ext/phar/func_interceptors.c | 2 | ||||
| -rwxr-xr-x | ext/spl/examples/dbaarray.inc | 5 | ||||
| -rwxr-xr-x | ext/spl/spl_directory.c | 15 | ||||
| -rw-r--r-- | ext/standard/basic_functions.c | 24 | ||||
| -rw-r--r-- | ext/standard/exec.c | 11 | ||||
| -rw-r--r-- | ext/standard/file.c | 76 | ||||
| -rw-r--r-- | ext/standard/php_string.h | 1 | ||||
| -rw-r--r-- | ext/standard/streamsfuncs.c | 15 | ||||
| -rw-r--r-- | ext/standard/string.c | 87 | ||||
| -rw-r--r-- | ext/sybase_ct/php_sybase_ct.c | 6 | ||||
| -rw-r--r-- | ext/zlib/zlib.c | 11 |
23 files changed, 86 insertions, 289 deletions
diff --git a/ext/bz2/bz2.c b/ext/bz2/bz2.c index 1e3c7b7617..310589fc10 100644 --- a/ext/bz2/bz2.c +++ b/ext/bz2/bz2.c @@ -352,13 +352,6 @@ static PHP_FUNCTION(bzread) } Z_STRVAL_P(return_value)[Z_STRLEN_P(return_value)] = 0; - - if (PG(magic_quotes_runtime)) { - Z_STRVAL_P(return_value) = php_addslashes( Z_STRVAL_P(return_value), - Z_STRLEN_P(return_value), - &Z_STRLEN_P(return_value), 1 TSRMLS_CC); - } - Z_TYPE_P(return_value) = IS_STRING; } /* }}} */ diff --git a/ext/dba/dba.c b/ext/dba/dba.c index 97b83d45a1..55fde32459 100644 --- a/ext/dba/dba.c +++ b/ext/dba/dba.c @@ -560,20 +560,9 @@ static void php_dba_update(INTERNAL_FUNCTION_PARAMETERS, int mode) DBA_WRITE_CHECK; - if (PG(magic_quotes_runtime)) { - v = estrndup(val, val_len); - php_stripslashes(v, &val_len TSRMLS_CC); - if (info->hnd->update(info, key_str, key_len, v, val_len, mode TSRMLS_CC) == SUCCESS) { - efree(v); - DBA_ID_DONE; - RETURN_TRUE; - } - efree(v); - } else { - if (info->hnd->update(info, key_str, key_len, val, val_len, mode TSRMLS_CC) == SUCCESS) { - DBA_ID_DONE; - RETURN_TRUE; - } + if (info->hnd->update(info, key_str, key_len, val, val_len, mode TSRMLS_CC) == SUCCESS) { + DBA_ID_DONE; + RETURN_TRUE; } DBA_ID_DONE; @@ -1029,9 +1018,6 @@ PHP_FUNCTION(dba_fetch) skip = 0; } if((val = info->hnd->fetch(info, key_str, key_len, skip, &len TSRMLS_CC)) != NULL) { - if (val && PG(magic_quotes_runtime)) { - val = php_addslashes(val, len, &len, 1 TSRMLS_CC); - } DBA_ID_DONE; RETURN_STRINGL(val, len, 0); } diff --git a/ext/exif/exif.c b/ext/exif/exif.c index f5e8374845..48af4d64dd 100644 --- a/ext/exif/exif.c +++ b/ext/exif/exif.c @@ -1697,11 +1697,7 @@ static void exif_iif_add_value(image_info_type *image_info, int section_index, c case TAG_FMT_STRING: if (value) { length = php_strnlen(value, length); - if (PG(magic_quotes_runtime)) { - info_value->s = php_addslashes(value, length, &length, 0 TSRMLS_CC); - } else { - info_value->s = estrndup(value, length); - } + info_value->s = estrndup(value, length); info_data->length = length; } else { info_data->length = 0; @@ -1724,11 +1720,7 @@ static void exif_iif_add_value(image_info_type *image_info, int section_index, c case TAG_FMT_UNDEFINED: if (value) { /* do not recompute length here */ - if (PG(magic_quotes_runtime)) { - info_value->s = php_addslashes(value, length, &length, 0 TSRMLS_CC); - } else { - info_value->s = estrndup(value, length); - } + info_value->s = estrndup(value, length); info_data->length = length; } else { info_data->length = 0; @@ -1850,11 +1842,7 @@ static void exif_iif_add_str(image_info_type *image_info, int section_index, cha info_data->format = TAG_FMT_STRING; info_data->length = 1; info_data->name = estrdup(name); - if (PG(magic_quotes_runtime)) { - info_data->value.s = php_addslashes(value, strlen(value), NULL, 0 TSRMLS_CC); - } else { - info_data->value.s = estrdup(value); - } + info_data->value.s = estrdup(value); image_info->sections_found |= 1<<section_index; image_info->info_list[section_index].count++; } @@ -1895,17 +1883,9 @@ static void exif_iif_add_buffer(image_info_type *image_info, int section_index, info_data->format = TAG_FMT_UNDEFINED; info_data->length = length; info_data->name = estrdup(name); - if (PG(magic_quotes_runtime)) { -#ifdef EXIF_DEBUG - exif_error_docref(NULL EXIFERR_CC, image_info, E_NOTICE, "Adding %s as buffer%s", name, exif_char_dump(value, length, 0)); -#endif - info_data->value.s = php_addslashes(value, length, &length, 0 TSRMLS_CC); - info_data->length = length; - } else { - info_data->value.s = safe_emalloc(length, 1, 1); - memcpy(info_data->value.s, value, length); - info_data->value.s[length] = 0; - } + info_data->value.s = safe_emalloc(length, 1, 1); + memcpy(info_data->value.s, value, length); + info_data->value.s[length] = 0; image_info->sections_found |= 1<<section_index; image_info->info_list[section_index].count++; } diff --git a/ext/filter/filter.c b/ext/filter/filter.c index e67bc7546d..6e61719060 100644 --- a/ext/filter/filter.c +++ b/ext/filter/filter.c @@ -464,8 +464,6 @@ static unsigned int php_sapi_filter(int arg, char *var, char **val, unsigned int Z_STRVAL(new_var) = estrndup(*val, val_len); INIT_PZVAL(tmp_new_var); php_zval_filter(&tmp_new_var, IF_G(default_filter), IF_G(default_filter_flags), NULL, NULL/*charset*/, 0 TSRMLS_CC); - } else if (PG(magic_quotes_gpc) && !retval) { /* for PARSE_STRING php_register_variable_safe() will do the addslashes() */ - Z_STRVAL(new_var) = php_addslashes(*val, Z_STRLEN(new_var), &Z_STRLEN(new_var), 0 TSRMLS_CC); } else { Z_STRVAL(new_var) = estrndup(*val, val_len); } diff --git a/ext/interbase/ibase_query.c b/ext/interbase/ibase_query.c index 9eac22284b..b1e1188aeb 100644 --- a/ext/interbase/ibase_query.c +++ b/ext/interbase/ibase_query.c @@ -1325,12 +1325,7 @@ static int _php_ibase_var_zval(zval *val, void *data, int type, int len, /* {{{ data = ((IBVARY *) data)->vary_string; /* no break */ case SQL_TEXT: - if (PG(magic_quotes_runtime)) { - Z_STRVAL_P(val) = php_addslashes(data, len, &Z_STRLEN_P(val), 0 TSRMLS_CC); - Z_TYPE_P(val) = IS_STRING; - } else { - ZVAL_STRINGL(val,(char *) data,len,1); - } + ZVAL_STRINGL(val,(char *) data,len,1); break; case SQL_SHORT: n = *(short *) data; diff --git a/ext/mcrypt/mcrypt.c b/ext/mcrypt/mcrypt.c index 609dac1d5f..7fecc1cca0 100644 --- a/ext/mcrypt/mcrypt.c +++ b/ext/mcrypt/mcrypt.c @@ -1387,7 +1387,7 @@ PHP_FUNCTION(mcrypt_create_iv) } iv = ecalloc(size + 1, 1); - + if (source == RANDOM || source == URANDOM) { #if PHP_WIN32 /* random/urandom equivalent on Windows */ diff --git a/ext/mssql/php_mssql.c b/ext/mssql/php_mssql.c index 3e00158334..f3af40bc2b 100644 --- a/ext/mssql/php_mssql.c +++ b/ext/mssql/php_mssql.c @@ -1520,27 +1520,17 @@ static void php_mssql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int result_type) if (Z_TYPE(result->data[result->cur_row][i]) != IS_NULL) { char *data; int data_len; - int should_copy; if (Z_TYPE(result->data[result->cur_row][i]) == IS_STRING) { - if (PG(magic_quotes_runtime)) { - data = php_addslashes(Z_STRVAL(result->data[result->cur_row][i]), Z_STRLEN(result->data[result->cur_row][i]), &data_len, 0 TSRMLS_CC); - should_copy = 0; - } - else - { - data = Z_STRVAL(result->data[result->cur_row][i]); - data_len = Z_STRLEN(result->data[result->cur_row][i]); - should_copy = 1; - } + data = Z_STRVAL(result->data[result->cur_row][i]); + data_len = Z_STRLEN(result->data[result->cur_row][i]); if (result_type & MSSQL_NUM) { - add_index_stringl(return_value, i, data, data_len, should_copy); - should_copy = 1; + add_index_stringl(return_value, i, data, data_len, 1); } if (result_type & MSSQL_ASSOC) { - add_assoc_stringl(return_value, result->fields[i].name, data, data_len, should_copy); + add_assoc_stringl(return_value, result->fields[i].name, data, data_len, 1); } } else if (Z_TYPE(result->data[result->cur_row][i]) == IS_LONG) { diff --git a/ext/mysql/php_mysql.c b/ext/mysql/php_mysql.c index df9dac549b..cfce37d5d5 100644 --- a/ext/mysql/php_mysql.c +++ b/ext/mysql/php_mysql.c @@ -1955,12 +1955,16 @@ Q: String or long first? if (sql_row[field_offset]) { Z_TYPE_P(return_value) = IS_STRING; +#if PHP_API_VERSION < 20100412 if (PG(magic_quotes_runtime)) { Z_STRVAL_P(return_value) = php_addslashes(sql_row[field_offset], sql_row_lengths[field_offset],&Z_STRLEN_P(return_value), 0 TSRMLS_CC); } else { +#endif Z_STRLEN_P(return_value) = sql_row_lengths[field_offset]; Z_STRVAL_P(return_value) = (char *) safe_estrndup(sql_row[field_offset], Z_STRLEN_P(return_value)); +#if PHP_API_VERSION < 20100412 } +#endif } else { Z_TYPE_P(return_value) = IS_NULL; } @@ -2078,12 +2082,16 @@ static void php_mysql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, long result_type, MAKE_STD_ZVAL(data); +#if PHP_API_VERSION < 20100412 if (PG(magic_quotes_runtime)) { Z_TYPE_P(data) = IS_STRING; Z_STRVAL_P(data) = php_addslashes(mysql_row[i], mysql_row_lengths[i], &Z_STRLEN_P(data), 0 TSRMLS_CC); } else { +#endif ZVAL_STRINGL(data, mysql_row[i], mysql_row_lengths[i], 1); +#if PHP_API_VERSION < 20100412 } +#endif if (result_type & MYSQL_NUM) { add_index_zval(return_value, i, data); diff --git a/ext/mysqli/mysqli.c b/ext/mysqli/mysqli.c index add2d123d8..b784ff863f 100644 --- a/ext/mysqli/mysqli.c +++ b/ext/mysqli/mysqli.c @@ -1137,13 +1137,17 @@ void php_mysqli_fetch_into_hash_aux(zval *return_value, MYSQL_RES * result, long #endif { +#if PHP_API_VERSION < 20100412 /* check if we need magic quotes */ if (PG(magic_quotes_runtime)) { Z_TYPE_P(res) = IS_STRING; Z_STRVAL_P(res) = php_addslashes(row[i], field_len[i], &Z_STRLEN_P(res), 0 TSRMLS_CC); } else { +#endif ZVAL_STRINGL(res, row[i], field_len[i], 1); +#if PHP_API_VERSION < 20100412 } +#endif } if (fetchtype & MYSQLI_NUM) { diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c index cc96fafe87..5e1a75394f 100644 --- a/ext/pcre/php_pcre.c +++ b/ext/pcre/php_pcre.c @@ -898,7 +898,7 @@ static int preg_do_eval(char *eval_str, int eval_str_len, char *subject, match = subject + offsets[backref<<1]; match_len = offsets[(backref<<1)+1] - offsets[backref<<1]; if (match_len) { - esc_match = php_addslashes_ex(match, match_len, &esc_match_len, 0, 1 TSRMLS_CC); + esc_match = php_addslashes(match, match_len, &esc_match_len, 0 TSRMLS_CC); } else { esc_match = match; esc_match_len = 0; diff --git a/ext/pdo/tests/pdo_test.inc b/ext/pdo/tests/pdo_test.inc index bbaeb71af7..f2e076793a 100644 --- a/ext/pdo/tests/pdo_test.inc +++ b/ext/pdo/tests/pdo_test.inc @@ -11,7 +11,6 @@ if (getenv('PDOTEST_DSN') === false) { $append = true; } } - if (ini_get('magic_quotes_runtime')) $common = stripslashes($common); $conf = eval($common); foreach($conf['ENV'] as $n=>$v) putenv("$n=$v"); } @@ -76,4 +75,4 @@ class PDOTest { return self::factory(); } } -?>
\ No newline at end of file +?> diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c index 9ab1a071e6..c2dd8b4a27 100644 --- a/ext/pgsql/pgsql.c +++ b/ext/pgsql/pgsql.c @@ -2499,12 +2499,8 @@ static void php_pgsql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, long result_type, int should_copy=0; const uint element_len = strlen(element); - if (PG(magic_quotes_runtime)) { - data = php_addslashes(element, element_len, &data_len, 0 TSRMLS_CC); - } else { - data = safe_estrndup(element, element_len); - data_len = element_len; - } + data = safe_estrndup(element, element_len); + data_len = element_len; if (result_type & PGSQL_NUM) { add_index_stringl(return_value, i, data, data_len, should_copy); @@ -6213,12 +6209,9 @@ PHP_PGSQL_API int php_pgsql_result2array(PGresult *pg_result, zval *ret_array TS size_t data_len; const size_t element_len = strlen(element); - if (PG(magic_quotes_runtime)) { - data = php_addslashes(element, element_len, &data_len, 0 TSRMLS_CC); - } else { - data = safe_estrndup(element, element_len); - data_len = element_len; - } + data = safe_estrndup(element, element_len); + data_len = element_len; + field_name = PQfname(pg_result, i); add_assoc_stringl(row, field_name, data, data_len, 0); } diff --git a/ext/phar/func_interceptors.c b/ext/phar/func_interceptors.c index 1b3f0f461b..d90aeac7ac 100644 --- a/ext/phar/func_interceptors.c +++ b/ext/phar/func_interceptors.c @@ -203,7 +203,7 @@ phar_it: /* uses mmap if possible */ if ((len = php_stream_copy_to_mem(stream, &contents, maxlen, 0)) > 0) { -#if PHP_MAJOR_VERSION < 6 +#if PHP_API_VERSION < 20100412 if (PG(magic_quotes_runtime)) { int newlen; contents = php_addslashes(contents, len, &newlen, 1 TSRMLS_CC); /* 1 = free source string */ diff --git a/ext/spl/examples/dbaarray.inc b/ext/spl/examples/dbaarray.inc index fcd6bb378a..d448ad7299 100755 --- a/ext/spl/examples/dbaarray.inc +++ b/ext/spl/examples/dbaarray.inc @@ -51,9 +51,6 @@ class DbaArray extends DbaReader implements ArrayAccess { $data = dba_fetch($name, $this->db); if($data) { - if (ini_get('magic_quotes_runtime')) { - $data = stripslashes($data); - } //return unserialize($data); return $data; } @@ -95,4 +92,4 @@ class DbaArray extends DbaReader implements ArrayAccess } } -?>
\ No newline at end of file +?> diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c index f1eaffe479..3c70550975 100755 --- a/ext/spl/spl_directory.c +++ b/ext/spl/spl_directory.c @@ -1993,7 +1993,6 @@ static int spl_filesystem_file_read(spl_filesystem_object *intern, int silent TS { char *buf; size_t line_len = 0; - int len; long line_add = (intern->u.file.current_line || intern->u.file.current_zval) ? 1 : 0; spl_filesystem_file_free_line(intern TSRMLS_CC); @@ -2026,11 +2025,6 @@ static int spl_filesystem_file_read(spl_filesystem_object *intern, int silent TS buf[line_len] = '\0'; } - if (PG(magic_quotes_runtime)) { - buf = php_addslashes(buf, line_len, &len, 1 TSRMLS_CC); - line_len = len; - } - intern->u.file.current_line = buf; intern->u.file.current_line_len = line_len; } @@ -2778,7 +2772,6 @@ SPL_METHOD(SplFileObject, fwrite) spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC); char *str; int str_len; - int ret; long length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &str, &str_len, &length) == FAILURE) { @@ -2792,14 +2785,6 @@ SPL_METHOD(SplFileObject, fwrite) RETURN_LONG(0); } - if (PG(magic_quotes_runtime)) { - str = estrndup(str, str_len); - php_stripslashes(str, &str_len TSRMLS_CC); - ret = php_stream_write(intern->u.file.stream, str, str_len); - efree(str); - RETURN_LONG(ret); - } - RETURN_LONG(php_stream_write(intern->u.file.stream, str, str_len)); } /* }}} */ diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index 6af19d6d18..4b5b9fe2c2 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -2964,8 +2964,8 @@ const zend_function_entry basic_functions[] = { /* {{{ */ PHP_DEP_FALIAS(magic_quotes_runtime, set_magic_quotes_runtime, arginfo_set_magic_quotes_runtime) PHP_DEP_FE(set_magic_quotes_runtime, arginfo_set_magic_quotes_runtime) - PHP_FE(get_magic_quotes_gpc, arginfo_get_magic_quotes_gpc) - PHP_FE(get_magic_quotes_runtime, arginfo_get_magic_quotes_runtime) + PHP_DEP_FE(get_magic_quotes_gpc, arginfo_get_magic_quotes_gpc) + PHP_DEP_FE(get_magic_quotes_runtime, arginfo_get_magic_quotes_runtime) PHP_FE(error_log, arginfo_error_log) PHP_FE(error_get_last, arginfo_error_get_last) @@ -4556,7 +4556,7 @@ PHP_FUNCTION(get_cfg_var) /* }}} */ /* {{{ proto bool set_magic_quotes_runtime(int new_setting) - Set the current active configuration setting of magic_quotes_runtime and return previous */ + magic_quotes_runtime is not supported anymore */ PHP_FUNCTION(set_magic_quotes_runtime) { zend_bool new_setting; @@ -4564,11 +4564,11 @@ PHP_FUNCTION(set_magic_quotes_runtime) if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &new_setting) == FAILURE) { return; } - - if (zend_alter_ini_entry_ex("magic_quotes_runtime", sizeof("magic_quotes_runtime"), new_setting ? "1" : "0", 1, PHP_INI_USER, PHP_INI_STAGE_RUNTIME, 0 TSRMLS_CC) == FAILURE) { - RETURN_FALSE; + + if (new_setting) { + php_error_docref(NULL TSRMLS_CC, E_CORE_ERROR, "magic_quotes_runtime is not supported anymore"); } - RETURN_TRUE; + RETURN_FALSE; } /* }}} */ @@ -4576,7 +4576,10 @@ PHP_FUNCTION(set_magic_quotes_runtime) Get the current active configuration setting of magic_quotes_runtime */ PHP_FUNCTION(get_magic_quotes_runtime) { - RETURN_LONG(PG(magic_quotes_runtime)); + if (zend_parse_parameters_none() == FAILURE) { + return; + } + RETURN_FALSE; } /* }}} */ @@ -4584,7 +4587,10 @@ PHP_FUNCTION(get_magic_quotes_runtime) Get the current active configuration setting of magic_quotes_gpc */ PHP_FUNCTION(get_magic_quotes_gpc) { - RETURN_LONG(PG(magic_quotes_gpc)); + if (zend_parse_parameters_none() == FAILURE) { + return; + } + RETURN_FALSE; } /* }}} */ diff --git a/ext/standard/exec.c b/ext/standard/exec.c index 890f73726b..ac96fe6815 100644 --- a/ext/standard/exec.c +++ b/ext/standard/exec.c @@ -60,7 +60,7 @@ PHPAPI int php_exec(int type, char *cmd, zval *array, zval *return_value TSRMLS_DC) { FILE *fp; - char *buf, *tmp=NULL; + char *buf; int l = 0, pclose_return; char *b, *d=NULL; php_stream *stream; @@ -139,14 +139,7 @@ PHPAPI int php_exec(int type, char *cmd, zval *array, zval *return_value TSRMLS_ } /* Return last line from the shell command */ - if (PG(magic_quotes_runtime)) { - int len; - - tmp = php_addslashes(buf, bufl, &len, 0 TSRMLS_CC); - RETVAL_STRINGL(tmp, len, 0); - } else { - RETVAL_STRINGL(buf, bufl, 1); - } + RETVAL_STRINGL(buf, bufl, 1); } else { /* should return NULL, but for BC we return "" */ RETVAL_EMPTY_STRING(); } diff --git a/ext/standard/file.c b/ext/standard/file.c index ddf7038840..ef5f215c36 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -423,13 +423,7 @@ PHP_FUNCTION(get_meta_tags) have_name = 1; } else if (saw_content) { STR_FREE(value); - /* Get the CONTENT attr (Single word attr, non-quoted) */ - if (PG(magic_quotes_runtime)) { - value = php_addslashes(md.token_data, 0, &md.token_len, 0 TSRMLS_CC); - } else { - value = estrndup(md.token_data, md.token_len); - } - + value = estrndup(md.token_data, md.token_len); have_content = 1; } @@ -463,13 +457,7 @@ PHP_FUNCTION(get_meta_tags) have_name = 1; } else if (saw_content) { STR_FREE(value); - /* Get the CONTENT attr (Single word attr, non-quoted) */ - if (PG(magic_quotes_runtime)) { - value = php_addslashes(md.token_data, 0, &md.token_len, 0 TSRMLS_CC); - } else { - value = estrndup(md.token_data, md.token_len); - } - + value = estrndup(md.token_data, md.token_len); have_content = 1; } @@ -561,11 +549,6 @@ PHP_FUNCTION(file_get_contents) } if ((len = php_stream_copy_to_mem(stream, &contents, maxlen, 0)) > 0) { - - if (PG(magic_quotes_runtime)) { - contents = php_addslashes(contents, len, &len, 1 TSRMLS_CC); /* 1 = free source string */ - } - RETVAL_STRINGL(contents, len, 0); } else if (len == 0) { RETVAL_EMPTY_STRING(); @@ -724,9 +707,9 @@ PHP_FUNCTION(file) { char *filename; int filename_len; - char *slashed, *target_buf=NULL, *p, *s, *e; + char *target_buf=NULL, *p, *s, *e; register int i = 0; - int target_len, len; + int target_len; char eol_marker = '\n'; long flags = 0; zend_bool use_include_path; @@ -778,13 +761,7 @@ PHP_FUNCTION(file) do { p++; parse_eol: - if (PG(magic_quotes_runtime)) { - /* s is in target_buf which is freed at the end of the function */ - slashed = php_addslashes(s, (p-s), &len, 0 TSRMLS_CC); - add_index_stringl(return_value, i++, slashed, len, 0); - } else { - add_index_stringl(return_value, i++, estrndup(s, p-s), p-s, 0); - } + add_index_stringl(return_value, i++, estrndup(s, p-s), p-s, 0); s = p; } while ((p = memchr(p, eol_marker, (e-p)))); } else { @@ -797,13 +774,7 @@ parse_eol: s = ++p; continue; } - if (PG(magic_quotes_runtime)) { - /* s is in target_buf which is freed at the end of the function */ - slashed = php_addslashes(s, (p-s-windows_eol), &len, 0 TSRMLS_CC); - add_index_stringl(return_value, i++, slashed, len, 0); - } else { - add_index_stringl(return_value, i++, estrndup(s, p-s-windows_eol), p-s-windows_eol, 0); - } + add_index_stringl(return_value, i++, estrndup(s, p-s-windows_eol), p-s-windows_eol, 0); s = ++p; } while ((p = memchr(p, eol_marker, (e-p)))); } @@ -1049,16 +1020,11 @@ PHPAPI PHP_FUNCTION(fgets) } } - if (PG(magic_quotes_runtime)) { - Z_STRVAL_P(return_value) = php_addslashes(buf, line_len, &Z_STRLEN_P(return_value), 1 TSRMLS_CC); - Z_TYPE_P(return_value) = IS_STRING; - } else { - ZVAL_STRINGL(return_value, buf, line_len, 0); - /* resize buffer if it's much larger than the result. - * Only needed if the user requested a buffer size. */ - if (argc > 1 && Z_STRLEN_P(return_value) < len / 2) { - Z_STRVAL_P(return_value) = erealloc(buf, line_len + 1); - } + ZVAL_STRINGL(return_value, buf, line_len, 0); + /* resize buffer if it's much larger than the result. + * Only needed if the user requested a buffer size. */ + if (argc > 1 && Z_STRLEN_P(return_value) < len / 2) { + Z_STRVAL_P(return_value) = erealloc(buf, line_len + 1); } return; @@ -1219,11 +1185,6 @@ PHPAPI PHP_FUNCTION(fwrite) PHP_STREAM_TO_ZVAL(stream, &arg1); - if (PG(magic_quotes_runtime)) { - buffer = estrndup(arg2, num_bytes); - php_stripslashes(buffer, &num_bytes TSRMLS_CC); - } - ret = php_stream_write(stream, buffer ? buffer : arg2, num_bytes); if (buffer) { efree(buffer); @@ -1790,11 +1751,6 @@ PHPAPI PHP_FUNCTION(fread) /* needed because recv/read/gzread doesnt put a null at the end*/ Z_STRVAL_P(return_value)[Z_STRLEN_P(return_value)] = 0; - - if (PG(magic_quotes_runtime)) { - Z_STRVAL_P(return_value) = php_addslashes(Z_STRVAL_P(return_value), - Z_STRLEN_P(return_value), &Z_STRLEN_P(return_value), 1 TSRMLS_CC); - } Z_TYPE_P(return_value) = IS_STRING; } /* }}} */ @@ -1950,15 +1906,7 @@ PHPAPI int php_fputcsv(php_stream *stream, zval *fields, char delimiter, char en smart_str_appendc(&csvline, '\n'); smart_str_0(&csvline); - if (!PG(magic_quotes_runtime)) { - ret = php_stream_write(stream, csvline.c, csvline.len); - } else { - char *buffer = estrndup(csvline.c, csvline.len); - int len = csvline.len; - php_stripslashes(buffer, &len TSRMLS_CC); - ret = php_stream_write(stream, buffer, len); - efree(buffer); - } + ret = php_stream_write(stream, csvline.c, csvline.len); smart_str_free(&csvline); diff --git a/ext/standard/php_string.h b/ext/standard/php_string.h index 23c703336a..c6d916dbcc 100644 --- a/ext/standard/php_string.h +++ b/ext/standard/php_string.h @@ -122,7 +122,6 @@ PHPAPI char *php_strtoupper(char *s, size_t len); PHPAPI char *php_strtolower(char *s, size_t len); PHPAPI char *php_strtr(char *str, int len, char *str_from, char *str_to, int trlen); PHPAPI char *php_addslashes(char *str, int length, int *new_length, int freeit TSRMLS_DC); -PHPAPI char *php_addslashes_ex(char *str, int length, int *new_length, int freeit, int ignore_sybase TSRMLS_DC); PHPAPI char *php_addcslashes(char *str, int length, int *new_length, int freeit, char *what, int wlength TSRMLS_DC); PHPAPI void php_stripslashes(char *str, int *len TSRMLS_DC); PHPAPI void php_stripcslashes(char *str, int *len); diff --git a/ext/standard/streamsfuncs.c b/ext/standard/streamsfuncs.c index befb13fd7a..54aef6afa0 100644 --- a/ext/standard/streamsfuncs.c +++ b/ext/standard/streamsfuncs.c @@ -395,13 +395,7 @@ PHP_FUNCTION(stream_socket_recvfrom) } read_buf[recvd] = '\0'; - if (PG(magic_quotes_runtime)) { - Z_TYPE_P(return_value) = IS_STRING; - Z_STRVAL_P(return_value) = php_addslashes(Z_STRVAL_P(return_value), Z_STRLEN_P(return_value), &Z_STRLEN_P(return_value), 1 TSRMLS_CC); - return; - } else { - RETURN_STRINGL(read_buf, recvd, 0); - } + RETURN_STRINGL(read_buf, recvd, 0); } efree(read_buf); @@ -417,8 +411,7 @@ PHP_FUNCTION(stream_get_contents) zval *zsrc; long maxlen = PHP_STREAM_COPY_ALL, desiredpos = -1L; - int len, - newlen; + int len; char *contents = NULL; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|ll", &zsrc, &maxlen, &desiredpos) == FAILURE) { @@ -450,10 +443,6 @@ PHP_FUNCTION(stream_get_contents) len = php_stream_copy_to_mem(stream, &contents, maxlen, 0); if (contents) { - if (len && PG(magic_quotes_runtime)) { - contents = php_addslashes(contents, len, &newlen, 1 TSRMLS_CC); /* 1 = free source string */ - len = newlen; - } RETVAL_STRINGL(contents, len, 0); } else { RETVAL_EMPTY_STRING(); diff --git a/ext/standard/string.c b/ext/standard/string.c index 44c5cd3b00..1717b3b711 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -3015,34 +3015,6 @@ PHPAPI void php_stripslashes(char *str, int *len TSRMLS_DC) s = str; t = str; - if (PG(magic_quotes_sybase)) { - while (l > 0) { - if (*t == '\'') { - if ((l > 0) && (t[1] == '\'')) { - t++; - if (len != NULL) { - (*len)--; - } - l--; - } - *s++ = *t++; - } else if (*t == '\\' && t[1] == '0' && l > 0) { - *s++='\0'; - t+=2; - if (len != NULL) { - (*len)--; - } - l--; - } else { - *s++ = *t++; - } - l--; - } - *s = '\0'; - - return; - } - while (l > 0) { if (*t == '\\') { t++; /* skip the slash */ @@ -3287,14 +3259,6 @@ PHPAPI char *php_addcslashes(char *str, int length, int *new_length, int should_ */ PHPAPI char *php_addslashes(char *str, int length, int *new_length, int should_free TSRMLS_DC) { - return php_addslashes_ex(str, length, new_length, should_free, 0 TSRMLS_CC); -} -/* }}} */ - -/* {{{ php_addslashes_ex - */ -PHPAPI char *php_addslashes_ex(char *str, int length, int *new_length, int should_free, int ignore_sybase TSRMLS_DC) -{ /* maximum string length, worst case situation */ char *new_str; char *source, *target; @@ -3313,42 +3277,23 @@ PHPAPI char *php_addslashes_ex(char *str, int length, int *new_length, int shoul end = source + length; target = new_str; - if (!ignore_sybase && PG(magic_quotes_sybase)) { - while (source < end) { - switch (*source) { - case '\0': - *target++ = '\\'; - *target++ = '0'; - break; - case '\'': - *target++ = '\''; - *target++ = '\''; - break; - default: - *target++ = *source; - break; - } - source++; - } - } else { - while (source < end) { - switch (*source) { - case '\0': - *target++ = '\\'; - *target++ = '0'; - break; - case '\'': - case '\"': - case '\\': - *target++ = '\\'; - /* break is missing *intentionally* */ - default: - *target++ = *source; - break; - } - - source++; + while (source < end) { + switch (*source) { + case '\0': + *target++ = '\\'; + *target++ = '0'; + break; + case '\'': + case '\"': + case '\\': + *target++ = '\\'; + /* break is missing *intentionally* */ + default: + *target++ = *source; + break; } + + source++; } *target = 0; diff --git a/ext/sybase_ct/php_sybase_ct.c b/ext/sybase_ct/php_sybase_ct.c index 129f687bd1..c07cdcd7e6 100644 --- a/ext/sybase_ct/php_sybase_ct.c +++ b/ext/sybase_ct/php_sybase_ct.c @@ -1814,11 +1814,7 @@ static void php_sybase_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int numerics) ALLOC_ZVAL(tmp); *tmp = result->data[result->store ? result->cur_row : 0][i]; INIT_PZVAL(tmp); - if (PG(magic_quotes_runtime) && Z_TYPE_P(tmp) == IS_STRING) { - Z_STRVAL_P(tmp) = php_addslashes(Z_STRVAL_P(tmp), Z_STRLEN_P(tmp), &Z_STRLEN_P(tmp), 0 TSRMLS_CC); - } else { - zval_copy_ctor(tmp); - } + zval_copy_ctor(tmp); if (numerics) { zend_hash_index_update(Z_ARRVAL_P(return_value), i, (void *) &tmp, sizeof(zval *), NULL); Z_ADDREF_P(tmp); diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c index 08450a3aa3..0f61bfde91 100644 --- a/ext/zlib/zlib.c +++ b/ext/zlib/zlib.c @@ -426,7 +426,7 @@ static PHP_FUNCTION(gzfile) char *filename; int filename_len; int flags = REPORT_ERRORS; - char *slashed, buf[8192] = {0}; + char buf[8192] = {0}; register int i = 0; long use_include_path = 0; php_stream *stream; @@ -454,14 +454,7 @@ static PHP_FUNCTION(gzfile) memset(buf, 0, sizeof(buf)); while (php_stream_gets(stream, buf, sizeof(buf) - 1) != NULL) { - if (PG(magic_quotes_runtime)) { - int len; - - slashed = php_addslashes(buf, 0, &len, 0 TSRMLS_CC); /* 0 = don't free source string */ - add_index_stringl(return_value, i++, slashed, len, 0); - } else { - add_index_string(return_value, i++, buf, 1); - } + add_index_string(return_value, i++, buf, 1); } php_stream_close(stream); } |
