31 Star 91 Fork 40

Justo/oneinstack

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
php5.3patch 2.10 KB
一键复制 编辑 原始数据 按行查看 历史
Justo 提交于 2018-04-14 10:43 +08:00 . Update phpMyAdmin
diff --git a/main/rfc1867.c b/main/rfc1867.c
index b3f94ec..7613119 100644
--- a/main/rfc1867.c
+++ b/main/rfc1867.c
@@ -33,6 +33,8 @@
#include "php_variables.h"
#include "rfc1867.h"
#include "ext/standard/php_string.h"
+#include "ext/standard/php_smart_str.h"
+
#define DEBUG_FILE_UPLOAD ZEND_DEBUG
@@ -462,6 +464,66 @@ static int find_boundary(multipart_buffer *self, char *boundary TSRMLS_DC)
static int multipart_buffer_headers(multipart_buffer *self, zend_llist *header TSRMLS_DC)
{
char *line;
+ mime_header_entry entry = {0};
+ smart_str buf_value = {0};
+ char *key = NULL;
+
+ /* didn't find boundary, abort */
+ if (!find_boundary(self, self->boundary TSRMLS_CC)) {
+ return 0;
+ }
+
+ /* get lines of text, or CRLF_CRLF */
+
+ while( (line = get_line(self TSRMLS_CC)) && line[0] != '\0' )
+ {
+ /* add header to table */
+ char *value = NULL;
+
+ /*if (php_rfc1867_encoding_translation(TSRMLS_C)) {
+ //self->input_encoding = zend_multibyte_encoding_detector((unsigned char *)line, strlen(line), self->detect_order, self->detect_order_size TSRMLS_CC);
+ }*/
+
+ /* space in the beginning means same header */
+ if (!isspace(line[0])) {
+ value = strchr(line, ':');
+ }
+
+ if (value) {
+ if(buf_value.c && key) {
+ /* new entry, add the old one to the list */
+ smart_str_0(&buf_value);
+ entry.key = key;
+ entry.value = buf_value.c;
+ zend_llist_add_element(header, &entry);
+ buf_value.c = NULL;
+ key = NULL;
+ }
+
+ *value = '\0';
+ do { value++; } while(isspace(*value));
+
+ key = estrdup(line);
+ smart_str_appends(&buf_value, value);
+ } else if (buf_value.c) { /* If no ':' on the line, add to previous line */
+ smart_str_appends(&buf_value, line);
+ } else {
+ continue;
+ }
+ }
+ if(buf_value.c && key) {
+ /* add the last one to the list */
+ smart_str_0(&buf_value);
+ entry.key = key;
+ entry.value = buf_value.c;
+ zend_llist_add_element(header, &entry);
+ }
+
+ return 1;
+}
+static int multipart_buffer_headers_bak(multipart_buffer *self, zend_llist *header TSRMLS_DC)
+{
+ char *line;
mime_header_entry prev_entry, entry;
int prev_len, cur_len;
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Shell
1
https://gitee.com/linuxeye/oneinstack.git
git@gitee.com:linuxeye/oneinstack.git
linuxeye
oneinstack
oneinstack
main

搜索帮助