php5.3patch 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. diff --git a/main/rfc1867.c b/main/rfc1867.c
  2. index b3f94ec..7613119 100644
  3. --- a/main/rfc1867.c
  4. +++ b/main/rfc1867.c
  5. @@ -33,6 +33,8 @@
  6. #include "php_variables.h"
  7. #include "rfc1867.h"
  8. #include "ext/standard/php_string.h"
  9. +#include "ext/standard/php_smart_str.h"
  10. +
  11. #define DEBUG_FILE_UPLOAD ZEND_DEBUG
  12. @@ -462,6 +464,66 @@ static int find_boundary(multipart_buffer *self, char *boundary TSRMLS_DC)
  13. static int multipart_buffer_headers(multipart_buffer *self, zend_llist *header TSRMLS_DC)
  14. {
  15. char *line;
  16. + mime_header_entry entry = {0};
  17. + smart_str buf_value = {0};
  18. + char *key = NULL;
  19. +
  20. + /* didn't find boundary, abort */
  21. + if (!find_boundary(self, self->boundary TSRMLS_CC)) {
  22. + return 0;
  23. + }
  24. +
  25. + /* get lines of text, or CRLF_CRLF */
  26. +
  27. + while( (line = get_line(self TSRMLS_CC)) && line[0] != '\0' )
  28. + {
  29. + /* add header to table */
  30. + char *value = NULL;
  31. +
  32. + /*if (php_rfc1867_encoding_translation(TSRMLS_C)) {
  33. + //self->input_encoding = zend_multibyte_encoding_detector((unsigned char *)line, strlen(line), self->detect_order, self->detect_order_size TSRMLS_CC);
  34. + }*/
  35. +
  36. + /* space in the beginning means same header */
  37. + if (!isspace(line[0])) {
  38. + value = strchr(line, ':');
  39. + }
  40. +
  41. + if (value) {
  42. + if(buf_value.c && key) {
  43. + /* new entry, add the old one to the list */
  44. + smart_str_0(&buf_value);
  45. + entry.key = key;
  46. + entry.value = buf_value.c;
  47. + zend_llist_add_element(header, &entry);
  48. + buf_value.c = NULL;
  49. + key = NULL;
  50. + }
  51. +
  52. + *value = '\0';
  53. + do { value++; } while(isspace(*value));
  54. +
  55. + key = estrdup(line);
  56. + smart_str_appends(&buf_value, value);
  57. + } else if (buf_value.c) { /* If no ':' on the line, add to previous line */
  58. + smart_str_appends(&buf_value, line);
  59. + } else {
  60. + continue;
  61. + }
  62. + }
  63. + if(buf_value.c && key) {
  64. + /* add the last one to the list */
  65. + smart_str_0(&buf_value);
  66. + entry.key = key;
  67. + entry.value = buf_value.c;
  68. + zend_llist_add_element(header, &entry);
  69. + }
  70. +
  71. + return 1;
  72. +}
  73. +static int multipart_buffer_headers_bak(multipart_buffer *self, zend_llist *header TSRMLS_DC)
  74. +{
  75. + char *line;
  76. mime_header_entry prev_entry, entry;
  77. int prev_len, cur_len;