mirror of
https://github.com/php/php-src.git
synced 2024-11-25 19:05:31 +08:00
MFB
This commit is contained in:
parent
cbcb1840f3
commit
373ae24839
@ -372,14 +372,15 @@ CWD_API char *virtual_getcwd(char *buf, size_t size TSRMLS_DC)
|
||||
|
||||
static inline unsigned long realpath_cache_key(const char *path, int path_len)
|
||||
{
|
||||
register unsigned long h;
|
||||
register unsigned long h;
|
||||
const char *e = path + path_len;
|
||||
|
||||
const char *e = path + path_len;
|
||||
for (h = 2166136261U; path < e; ) {
|
||||
h *= 16777619;
|
||||
h ^= *path++;
|
||||
}
|
||||
return h;
|
||||
for (h = 2166136261U; path < e;) {
|
||||
h *= 16777619;
|
||||
h ^= *path++;
|
||||
}
|
||||
|
||||
return h;
|
||||
}
|
||||
|
||||
CWD_API void realpath_cache_clean(TSRMLS_D)
|
||||
@ -436,7 +437,7 @@ static inline void realpath_cache_add(const char *path, int path_len, const char
|
||||
n = bucket->key % (sizeof(CWDG(realpath_cache)) / sizeof(CWDG(realpath_cache)[0]));
|
||||
bucket->next = CWDG(realpath_cache)[n];
|
||||
CWDG(realpath_cache)[n] = bucket;
|
||||
CWDG(realpath_cache_size) += size;
|
||||
CWDG(realpath_cache_size) += size;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -363,8 +363,8 @@ static int php_iconv_output_handler(void **nothing, php_output_context *output_c
|
||||
}
|
||||
|
||||
if (mimetype != NULL && !(output_context->op & PHP_OUTPUT_HANDLER_CLEAN)) {
|
||||
spprintf(&content_type, 0, "Content-Type: %.*s; charset=%s", mimetype_len?mimetype_len:strlen(mimetype), mimetype, ICONVG(output_encoding));
|
||||
if (content_type && SUCCESS == sapi_add_header(content_type, strlen(content_type), 0)) {
|
||||
int len = spprintf(&content_type, 0, "Content-Type: %.*s; charset=%s", mimetype_len?mimetype_len:strlen(mimetype), mimetype, ICONVG(output_encoding));
|
||||
if (content_type && SUCCESS == sapi_add_header(content_type, len, 0)) {
|
||||
SG(sapi_headers).send_default_content_type = 0;
|
||||
php_output_handler_hook(PHP_OUTPUT_HANDLER_HOOK_IMMUTABLE, NULL TSRMLS_CC);
|
||||
}
|
||||
|
@ -146,11 +146,12 @@ php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, char *path,
|
||||
char *protocol_version = NULL;
|
||||
int protocol_version_len = 3; /* Default: "1.0" */
|
||||
char *charset = NULL;
|
||||
struct timeval timeout;
|
||||
|
||||
tmp_line[0] = '\0';
|
||||
|
||||
if (redirect_max < 1) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Redirection limit reached, aborting");
|
||||
php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "Redirection limit reached, aborting");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -202,9 +203,23 @@ php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, char *path,
|
||||
}
|
||||
}
|
||||
|
||||
if (context && php_stream_context_get_option(context, wrapper->wops->label, "timeout", &tmpzval) == SUCCESS) {
|
||||
SEPARATE_ZVAL(tmpzval);
|
||||
convert_to_double_ex(tmpzval);
|
||||
timeout.tv_sec = (time_t) Z_DVAL_PP(tmpzval);
|
||||
timeout.tv_usec = (size_t) ((Z_DVAL_PP(tmpzval) - timeout.tv_sec) * 1000000);
|
||||
} else {
|
||||
timeout.tv_sec = FG(default_socket_timeout);
|
||||
timeout.tv_usec = 0;
|
||||
}
|
||||
|
||||
stream = php_stream_xport_create(transport_string, transport_len, options,
|
||||
STREAM_XPORT_CLIENT | STREAM_XPORT_CONNECT,
|
||||
NULL, NULL, context, &errstr, NULL);
|
||||
NULL, &timeout, context, &errstr, NULL);
|
||||
|
||||
if (stream) {
|
||||
php_stream_set_option(stream, PHP_STREAM_OPTION_READ_TIMEOUT, 0, &timeout);
|
||||
}
|
||||
|
||||
if (errstr) {
|
||||
php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "%s", errstr);
|
||||
@ -275,8 +290,7 @@ php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, char *path,
|
||||
redirect_max = Z_LVAL_PP(tmpzval);
|
||||
}
|
||||
|
||||
if (header_init && context &&
|
||||
php_stream_context_get_option(context, "http", "method", &tmpzval) == SUCCESS) {
|
||||
if (context && php_stream_context_get_option(context, "http", "method", &tmpzval) == SUCCESS) {
|
||||
if (Z_TYPE_PP(tmpzval) == IS_STRING && Z_STRLEN_PP(tmpzval) > 0) {
|
||||
scratch_len = strlen(path) + 29 + Z_STRLEN_PP(tmpzval);
|
||||
scratch = emalloc(scratch_len);
|
||||
@ -284,9 +298,8 @@ php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, char *path,
|
||||
strcat(scratch, " ");
|
||||
}
|
||||
}
|
||||
|
||||
if (context &&
|
||||
php_stream_context_get_option(context, "http", "protocol_version", &tmpzval) == SUCCESS) {
|
||||
|
||||
if (context && php_stream_context_get_option(context, "http", "protocol_version", &tmpzval) == SUCCESS) {
|
||||
SEPARATE_ZVAL(tmpzval);
|
||||
convert_to_double_ex(tmpzval);
|
||||
protocol_version_len = spprintf(&protocol_version, 0, "%.1F", Z_DVAL_PP(tmpzval));
|
||||
@ -612,7 +625,11 @@ php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, char *path,
|
||||
}
|
||||
}
|
||||
|
||||
if (!reqok || location[0] != '\0') {
|
||||
if (!reqok || location[0] != '\0') {
|
||||
if (options & STREAM_ONLY_GET_HEADERS && redirect_max <= 1) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (location[0] != '\0')
|
||||
php_stream_notify_info(context, PHP_STREAM_NOTIFY_REDIRECTED, location, 0);
|
||||
|
||||
|
@ -50,35 +50,24 @@ int php_url_scanner_deactivate(TSRMLS_D)
|
||||
static char *url_attr_addon(const char *tag,const char *attr,const char *val,const char *buf)
|
||||
{
|
||||
int flag = 0;
|
||||
TSRMLS_FETCH();
|
||||
|
||||
if(!strcasecmp(tag,"a") && !strcasecmp(attr,"href")) {
|
||||
if (!strcasecmp(tag,"a") && !strcasecmp(attr,"href")) {
|
||||
flag = 1;
|
||||
} else if(!strcasecmp(tag,"area" ) && !strcasecmp(attr,"href" )) {
|
||||
} else if (!strcasecmp(tag,"area" ) && !strcasecmp(attr,"href" )) {
|
||||
flag = 1;
|
||||
} else if(!strcasecmp(tag,"form" ) && !strcasecmp(attr,"action" )) {
|
||||
} else if (!strcasecmp(tag,"form" ) && !strcasecmp(attr,"action" )) {
|
||||
flag = 1;
|
||||
} else if(!strcasecmp(tag,"frame") && !strcasecmp(attr,"source" )) {
|
||||
} else if (!strcasecmp(tag,"frame") && !strcasecmp(attr,"source" )) {
|
||||
flag = 1;
|
||||
} else if(!strcasecmp(tag,"img" ) && !strcasecmp(attr,"action" )) {
|
||||
} else if (!strcasecmp(tag,"img" ) && !strcasecmp(attr,"action" )) {
|
||||
flag = 1;
|
||||
}
|
||||
if(flag) {
|
||||
if(!strstr(val,buf)&&!strchr(val,':'))
|
||||
{
|
||||
char *result = (char *)emalloc(strlen(buf)+strlen(PG(arg_separator).output)+1);
|
||||
int n;
|
||||
if(flag && !strstr(val,buf) && !strchr(val,':')) {
|
||||
char *result;
|
||||
TSRMLS_FETCH();
|
||||
|
||||
if(strchr(val,'?')) {
|
||||
strcpy(result,PG(arg_separator).output);
|
||||
n=strlen(PG(arg_separator).output);
|
||||
} else {
|
||||
*result='?';
|
||||
n=1;
|
||||
}
|
||||
strcpy(result+n,buf);
|
||||
return result;
|
||||
}
|
||||
spprintf(&result, 0, "%s%s", (strchr(val,'?') ? PG(arg_separator).output : "?"), buf);
|
||||
return result;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@ -214,7 +203,7 @@ char *url_adapt(const char *src, size_t srclen, const char *data, size_t *newlen
|
||||
maxl+=l;
|
||||
out=realloc(out,maxl);
|
||||
outp=out+*newlen;
|
||||
strcpy(outp,p);
|
||||
strlcpy(outp,p,maxl);
|
||||
outp+=l;
|
||||
*newlen+=l;
|
||||
efree(p);
|
||||
@ -230,7 +219,7 @@ char *url_adapt(const char *src, size_t srclen, const char *data, size_t *newlen
|
||||
maxl+=l;
|
||||
out=realloc(out,maxl);
|
||||
outp=out+*newlen;
|
||||
strcpy(outp,p);
|
||||
strlcpy(outp, p, maxl);
|
||||
outp+=l;
|
||||
*newlen+=l;
|
||||
efree(p);
|
||||
@ -265,7 +254,7 @@ char *url_adapt(const char *src, size_t srclen, const char *data, size_t *newlen
|
||||
maxl+=l;
|
||||
out=realloc(out,maxl);
|
||||
outp=out+*newlen;
|
||||
strcpy(outp,p);
|
||||
strlcpy(outp,p,maxl);
|
||||
outp+=l;
|
||||
*newlen+=l;
|
||||
efree(p);
|
||||
@ -282,7 +271,7 @@ char *url_adapt(const char *src, size_t srclen, const char *data, size_t *newlen
|
||||
maxl+=l;
|
||||
out=realloc(out,maxl);
|
||||
outp=out+*newlen;
|
||||
strcpy(outp,p);
|
||||
strlcpy(outp,p,maxl);
|
||||
outp+=l;
|
||||
*newlen+=l;
|
||||
efree(p);
|
||||
@ -329,7 +318,7 @@ char *url_adapt(const char *src, size_t srclen, const char *data, size_t *newlen
|
||||
maxl+=l;
|
||||
out=realloc(out,maxl);
|
||||
outp=out+*newlen;
|
||||
strcpy(outp,p);
|
||||
strlcpy(outp,p,maxl);
|
||||
outp+=l;
|
||||
*newlen+=l;
|
||||
efree(p);
|
||||
@ -346,7 +335,7 @@ char *url_adapt(const char *src, size_t srclen, const char *data, size_t *newlen
|
||||
maxl+=l;
|
||||
out=realloc(out,maxl);
|
||||
outp=out+*newlen;
|
||||
strcpy(outp,p);
|
||||
strlcpy(outp,p,maxl);
|
||||
outp+=l;
|
||||
*newlen+=l;
|
||||
efree(p);
|
||||
|
@ -37,21 +37,21 @@ static sapi_post_entry php_post_entries[] = {
|
||||
*/
|
||||
SAPI_API SAPI_POST_READER_FUNC(php_default_post_reader)
|
||||
{
|
||||
char *data = NULL;
|
||||
int length = 0;
|
||||
char *data;
|
||||
int length;
|
||||
|
||||
/* $HTTP_RAW_POST_DATA registration */
|
||||
if(!strcmp(SG(request_info).request_method, "POST")) {
|
||||
if(NULL == SG(request_info).post_entry) {
|
||||
if (!strcmp(SG(request_info).request_method, "POST")) {
|
||||
if (NULL == SG(request_info).post_entry) {
|
||||
/* no post handler registered, so we just swallow the data */
|
||||
sapi_read_standard_form_data(TSRMLS_C);
|
||||
length = SG(request_info).post_data_length;
|
||||
data = estrndup(SG(request_info).post_data, length);
|
||||
} else if(PG(always_populate_raw_post_data) && SG(request_info).post_data) {
|
||||
length = SG(request_info).post_data_length;
|
||||
data = estrndup(SG(request_info).post_data, length);
|
||||
}
|
||||
if(data) {
|
||||
|
||||
/* For unknown content types we create HTTP_RAW_POST_DATA even if always_populate_raw_post_data off,
|
||||
* this is in-effecient, but we need to keep doing it for BC reasons (for now) */
|
||||
if ((PG(always_populate_raw_post_data) || NULL == SG(request_info).post_entry) && SG(request_info).post_data) {
|
||||
length = SG(request_info).post_data_length;
|
||||
data = estrndup(SG(request_info).post_data, length);
|
||||
SET_VAR_STRINGL("HTTP_RAW_POST_DATA", data, length);
|
||||
}
|
||||
}
|
||||
@ -62,11 +62,10 @@ SAPI_API SAPI_POST_READER_FUNC(php_default_post_reader)
|
||||
in the long run post handlers should be changed to not touch
|
||||
request_info.post_data for memory preservation reasons
|
||||
*/
|
||||
if(SG(request_info).post_data) {
|
||||
if (SG(request_info).post_data) {
|
||||
SG(request_info).raw_post_data = estrndup(SG(request_info).post_data, SG(request_info).post_data_length);
|
||||
SG(request_info).raw_post_data_length = SG(request_info).post_data_length;
|
||||
}
|
||||
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
@ -1391,6 +1391,15 @@ TEST $file
|
||||
} elseif (array_key_exists('POST', $section_text) && !empty($section_text['POST'])) {
|
||||
|
||||
$post = trim($section_text['POST']);
|
||||
|
||||
if (array_key_exists('GZIP_POST', $section_text) && function_exists('gzencode')) {
|
||||
$post = gzencode($post, 9, FORCE_GZIP);
|
||||
$env['HTTP_CONTENT_ENCODING'] = 'gzip';
|
||||
} else if (array_key_exists('DEFLATE_POST', $section_text) && function_exists('gzcompress')) {
|
||||
$post = gzcompress($post, 9);
|
||||
$env['HTTP_CONTENT_ENCODING'] = 'deflate';
|
||||
}
|
||||
|
||||
save_text($tmp_post, $post);
|
||||
$content_length = strlen($post);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user