pollita         Mon Apr 17 19:25:48 2006 UTC

  Modified files:              
    /php-src/ext/standard       filters.c 
  Log:
  Fix 'soft line break' handling in convert.quoted-printable-decode
  
http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/filters.c?r1=1.54&r2=1.55&diff_format=u
Index: php-src/ext/standard/filters.c
diff -u php-src/ext/standard/filters.c:1.54 php-src/ext/standard/filters.c:1.55
--- php-src/ext/standard/filters.c:1.54 Mon Mar 20 20:09:20 2006
+++ php-src/ext/standard/filters.c      Mon Apr 17 19:25:48 2006
@@ -20,7 +20,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: filters.c,v 1.54 2006/03/20 20:09:20 tony2001 Exp $ */
+/* $Id: filters.c,v 1.55 2006/04/17 19:25:48 pollita Exp $ */
 
 #include "php.h"
 #include "php_globals.h"
@@ -1108,6 +1108,18 @@
                                        scan_stat = 4;
                                        ps++, icnt--;
                                        break;
+                               } else if (!inst->lbchars && lb_cnt == 0 && *ps 
== '\r') {
+                                       /* auto-detect line endings, looks like 
network line ending \r\n (could be mac \r) */
+                                       lb_cnt++;
+                                       scan_stat = 5;
+                                       ps++, icnt--;
+                                       break;
+                               } else if (!inst->lbchars && lb_cnt == 0 && *ps 
== '\n') {
+                                       /* auto-detect line endings, looks like 
unix-lineendings, not to spec, but it is seem in the wild, a lot */
+                                       lb_cnt = lb_ptr = 0;
+                                       scan_stat = 0;
+                                       ps++, icnt--;
+                                       break;
                                } else if (lb_cnt < inst->lbchars_len &&
                                                        *ps == (unsigned 
char)inst->lbchars[lb_cnt]) {
                                        lb_cnt++;
@@ -1165,7 +1177,16 @@
                        } break;
 
                        case 5: {
-                               if (lb_cnt >= inst->lbchars_len) {
+                               if (!inst->lbchars && lb_cnt == 1 && *ps == 
'\n') {
+                                       /* auto-detect soft line breaks, found 
network line break */
+                                       lb_cnt = lb_ptr = 0;
+                                       scan_stat = 0;
+                                       ps++, icnt--; /* consume \n */
+                               } else if (!inst->lbchars && lb_cnt > 0) {
+                                       /* auto-detect soft line breaks, found 
mac line break */
+                                       lb_cnt = lb_ptr = 0;
+                                       scan_stat = 0;
+                               } else if (lb_cnt >= inst->lbchars_len) {
                                        /* soft line break */
                                        lb_cnt = lb_ptr = 0;
                                        scan_stat = 0;
@@ -1486,10 +1507,6 @@
 
                        if (options != NULL) {
                                GET_STR_PROP(options, lbchars, lbchars_len, 
"line-break-chars", 0);
-                               if (lbchars == NULL) {
-                                       lbchars = pestrdup("\r\n", 0);
-                                       lbchars_len = 2;
-                               }
                        }
                        retval = pemalloc(sizeof(php_conv_qprint_decode), 
persistent);
                        if (lbchars != NULL) {

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to