diff options
Diffstat (limited to 'ext/standard')
| -rw-r--r-- | ext/standard/basic_functions.c | 39 | ||||
| -rw-r--r-- | ext/standard/exec.c | 9 | ||||
| -rw-r--r-- | ext/standard/file.c | 66 | ||||
| -rw-r--r-- | ext/standard/streamsfuncs.c | 15 | ||||
| -rw-r--r-- | ext/standard/string.c | 157 | ||||
| -rwxr-xr-x | ext/standard/tests/file/fputcsv.phpt | 2 | ||||
| -rw-r--r-- | ext/standard/tests/strings/add-and-stripslashes.phpt | 11 |
7 files changed, 48 insertions, 251 deletions
diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index ab7d375569..9681db53c0 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -442,11 +442,11 @@ zend_function_entry basic_functions[] = { PHP_FE(get_current_user, NULL) PHP_FE(set_time_limit, NULL) PHP_FE(get_cfg_var, NULL) - PHP_FALIAS(magic_quotes_runtime, set_magic_quotes_runtime, NULL) - PHP_FE(set_magic_quotes_runtime, NULL) - PHP_FE(get_magic_quotes_gpc, NULL) - PHP_FE(get_magic_quotes_runtime, NULL) - + PHP_DEP_FALIAS(magic_quotes_runtime, set_magic_quotes_runtime, NULL) + PHP_DEP_FE(set_magic_quotes_runtime, NULL) + PHP_DEP_FE(get_magic_quotes_gpc, NULL) + PHP_DEP_FE(get_magic_quotes_runtime, NULL) + PHP_FE(import_request_variables, NULL) PHP_FE(error_log, NULL) PHP_FE(call_user_func, NULL) @@ -1151,9 +1151,6 @@ PHP_RINIT_FUNCTION(basic) PHP_RINIT(dir)(INIT_FUNC_ARGS_PASSTHRU); PHP_RINIT(url_scanner_ex)(INIT_FUNC_ARGS_PASSTHRU); - /* Reset magic_quotes_runtime */ - PG(magic_quotes_runtime) = INI_BOOL("magic_quotes_runtime"); - /* Setup default context */ FG(default_context) = NULL; @@ -1823,38 +1820,20 @@ 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 */ PHP_FUNCTION(set_magic_quotes_runtime) { - zval **new_setting; - - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &new_setting) == FAILURE) { - RETURN_FALSE; - } - convert_to_boolean_ex(new_setting); - - PG(magic_quotes_runtime) = (zend_bool) Z_LVAL_PP(new_setting); - RETURN_TRUE; + php_error_docref(NULL TSRMLS_CC, E_CORE_ERROR, "magic_quotes_runtime is not supported anymore"); + RETURN_FALSE; } -/* }}} */ -/* {{{ proto int get_magic_quotes_runtime(void) - Get the current active configuration setting of magic_quotes_runtime */ PHP_FUNCTION(get_magic_quotes_runtime) { - RETURN_LONG(PG(magic_quotes_runtime)); + RETURN_FALSE; } - -/* }}} */ - -/* {{{ proto int get_magic_quotes_gpc(void) - Get the current active configuration setting of magic_quotes_gpc */ PHP_FUNCTION(get_magic_quotes_gpc) { - RETURN_LONG(PG(magic_quotes_gpc)); + RETURN_FALSE; } -/* }}} */ /* 1st arg = error message diff --git a/ext/standard/exec.c b/ext/standard/exec.c index 3fa0462aa5..1dccf6610c 100644 --- a/ext/standard/exec.c +++ b/ext/standard/exec.c @@ -135,14 +135,7 @@ int php_exec(int type, char *cmd, zval *array, zval *return_value TSRMLS_DC) } /* 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 88d4062c6f..f3ad871faa 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -413,11 +413,7 @@ PHP_FUNCTION(get_meta_tags) have_name = 1; } else if (saw_content) { /* 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; } @@ -451,11 +447,7 @@ PHP_FUNCTION(get_meta_tags) have_name = 1; } else if (saw_content) { /* 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; } @@ -543,12 +535,6 @@ PHP_FUNCTION(file_get_contents) /* uses mmap if possible */ if ((len = php_stream_copy_to_mem(stream, &contents, maxlen, 0)) > 0) { - - if (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 if (len == 0) { RETVAL_EMPTY_STRING(); @@ -778,13 +764,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 { @@ -793,13 +773,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), &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)))); } @@ -1038,18 +1012,9 @@ PHPAPI PHP_FUNCTION(fgets) } if (is_unicode) { - /* UTODO: magic_quotes_runtime */ RETURN_UNICODEL(buf, num_chars, 0); } else { - if (PG(magic_quotes_runtime)) { - int len; - char *str; - - str = php_addslashes((char*)buf, num_bytes, &len, 1 TSRMLS_CC); - RETURN_STRINGL(str, len, 0); - } else { RETURN_STRINGL((char*)buf, num_bytes, 0); - } } } /* }}} */ @@ -1248,9 +1213,6 @@ PHPAPI PHP_FUNCTION(fwrite) if (write_len < 0 || write_len > Z_USTRLEN_P(zstring)) { write_len = Z_USTRLEN_P(zstring); } - - /* UTODO Handle magic_quotes_runtime for unicode strings */ - ret = php_stream_u_write(stream, Z_USTRVAL_P(zstring), write_len); /* Convert data points back to code units */ @@ -1267,10 +1229,6 @@ PHPAPI PHP_FUNCTION(fwrite) } num_bytes = write_len; - if (argc < 3 && PG(magic_quotes_runtime)) { - buffer = estrndup(Z_STRVAL_P(zstring), num_bytes); - php_stripslashes(buffer, &num_bytes TSRMLS_CC); - } ret = php_stream_write(stream, buffer ? buffer : Z_STRVAL_P(zstring), num_bytes); if (buffer) { efree(buffer); @@ -1828,16 +1786,11 @@ PHPAPI PHP_FUNCTION(fread) } if (is_unicode) { - /* UTODO - magic_quotes_runtime */ - buf[num_bytes] = 0; buf[num_bytes + 1] = 0; RETURN_UNICODEL((UChar *)buf, num_bytes >> 1, 0); } else { buf[num_bytes] = 0; - if (PG(magic_quotes_runtime)) { - buf = php_addslashes(buf, num_bytes, &num_bytes, 1 TSRMLS_CC); - } RETURN_STRINGL(buf, num_bytes, 0); } } @@ -1976,16 +1929,7 @@ PHP_FUNCTION(fputcsv) 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); RETURN_LONG(ret); diff --git a/ext/standard/streamsfuncs.c b/ext/standard/streamsfuncs.c index 569dc47be4..0d3050d149 100644 --- a/ext/standard/streamsfuncs.c +++ b/ext/standard/streamsfuncs.c @@ -370,14 +370,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); @@ -407,12 +400,6 @@ PHP_FUNCTION(stream_get_contents) } if ((len = php_stream_copy_to_mem(stream, &contents, maxlen, 0)) > 0) { - - if (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 if (len == 0) { RETVAL_EMPTY_STRING(); diff --git a/ext/standard/string.c b/ext/standard/string.c index 7b9f677788..eca1d998a6 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -3798,48 +3798,19 @@ PHPAPI void php_u_stripslashes(UChar *str, int *len TSRMLS_DC) UChar32 ch1, ch2; ch1 = -1; ch2 = -1; - if (PG(magic_quotes_sybase)) { - while (i < src_len) { - U16_NEXT(str, i, src_len, ch1); - if (ch1 == '\'') { - tmp_len += zend_codepoint_to_uchar(ch1, str+tmp_len); - if (i < src_len) { - U16_NEXT(str, i, src_len, ch2); - if (ch2 != '\'') { - tmp_len += zend_codepoint_to_uchar(ch2, str+tmp_len); - } - } - } else if (ch1 == '\\') { - if (i < src_len) { - U16_NEXT(str, i, src_len, ch2); - if (ch2 == '0') { - tmp_len += zend_codepoint_to_uchar('\0', str+tmp_len); - } else { - tmp_len += zend_codepoint_to_uchar(ch1, str+tmp_len); - tmp_len += zend_codepoint_to_uchar(ch2, str+tmp_len); - } + while (i < src_len) { + U16_NEXT(str, i, src_len, ch1); + if (ch1 == '\\') { + if (i < src_len) { + U16_NEXT(str, i, src_len, ch2); + if (ch2 == '0') { + tmp_len += zend_codepoint_to_uchar('\0', str+tmp_len); } else { - tmp_len += zend_codepoint_to_uchar(ch1, str+tmp_len); + tmp_len += zend_codepoint_to_uchar(ch2, str+tmp_len); } - } else { - tmp_len += zend_codepoint_to_uchar(ch1, str+tmp_len); - } - } - } else { - while (i < src_len) { - U16_NEXT(str, i, src_len, ch1); - if (ch1 == '\\') { - if (i < src_len) { - U16_NEXT(str, i, src_len, ch2); - if (ch2 == '0') { - tmp_len += zend_codepoint_to_uchar('\0', str+tmp_len); - } else { - tmp_len += zend_codepoint_to_uchar(ch2, str+tmp_len); - } - } - } else { - tmp_len += zend_codepoint_to_uchar(ch1, str+tmp_len); } + } else { + tmp_len += zend_codepoint_to_uchar(ch1, str+tmp_len); } } *(str+tmp_len) = 0; @@ -3865,34 +3836,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 */ @@ -4179,42 +4122,25 @@ PHPAPI UChar *php_u_addslashes_ex(UChar *str, int length, int *new_length, int s } buf = eumalloc(length * 2); - if (!ignore_sybase && PG(magic_quotes_sybase)) { - while (i < length) { - U16_NEXT(str, i, length, ch); - switch (ch) { - case '\0': - *(buf+buf_len) = (UChar)0x5C; buf_len++; /* \ */ - *(buf+buf_len) = (UChar)0x30; buf_len++; /* 0 */ - break; - case '\'': - *(buf+buf_len) = (UChar)0x27; buf_len++; /* ' */ - *(buf+buf_len) = (UChar)0x27; buf_len++; /* ' */ - break; - default: - buf_len += zend_codepoint_to_uchar(ch, buf+buf_len); - break; - } - } - } else { - while (i < length) { - U16_NEXT(str, i, length, ch); - switch (ch) { + + while (i < length) { + U16_NEXT(str, i, length, ch); + switch (ch) { case '\0': *(buf+buf_len) = (UChar)0x5C; buf_len++; /* \ */ *(buf+buf_len) = (UChar)0x30; buf_len++; /* 0 */ break; case '\'': - case '\"': + case '\"': case '\\': - *(buf+buf_len) = (UChar)0x5C; buf_len++; /* \ */ - /* break is missing *intentionally* */ + *(buf+buf_len) = (UChar)0x5C; buf_len++; /* \ */ + /* break is missing *intentionally* */ default: - buf_len += zend_codepoint_to_uchar(ch, buf+buf_len); - break; - } + buf_len += zend_codepoint_to_uchar(ch, buf+buf_len); + break; } } + *(buf+buf_len) = 0; if (should_free) { @@ -4256,44 +4182,25 @@ 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 '\'': + while (source < end) { + switch (*source) { + case '\0': + *target++ = '\\'; + *target++ = '0'; + break; + case '\'': case '\"': - case '\\': + case '\\': *target++ = '\\'; /* break is missing *intentionally* */ - default: + default: *target++ = *source; break; - } - - source++; } + + source++; } - + *target = 0; *new_length = target - new_str; if (should_free) { diff --git a/ext/standard/tests/file/fputcsv.phpt b/ext/standard/tests/file/fputcsv.phpt index 486d10a1fc..e4f91fa9f4 100755 --- a/ext/standard/tests/file/fputcsv.phpt +++ b/ext/standard/tests/file/fputcsv.phpt @@ -1,7 +1,5 @@ --TEST-- various fputcsv() functionality tests ---INI-- -magic_quotes_runtime=0 --FILE-- <?php diff --git a/ext/standard/tests/strings/add-and-stripslashes.phpt b/ext/standard/tests/strings/add-and-stripslashes.phpt index a5eab410b9..f4483c031e 100644 --- a/ext/standard/tests/strings/add-and-stripslashes.phpt +++ b/ext/standard/tests/strings/add-and-stripslashes.phpt @@ -9,22 +9,11 @@ for($i=0; $i<512; $i++) { } echo "Normal: "; -ini_set('magic_quotes_sybase', 0); if($input === stripslashes(addslashes($input))) { echo "OK\n"; } else { echo "FAILED\n"; } - -echo "Sybase: "; -ini_set('magic_quotes_sybase', 1); -if($input === stripslashes(addslashes($input))) { - echo "OK\n"; -} else { - echo "FAILED\n"; -} - ?> --EXPECT-- Normal: OK -Sybase: OK |
