pollita Mon Apr 17 19:26:05 2006 UTC
Modified files: (Branch: PHP_5_1)
/php-src/ext/standard filters.c
Log:
MFH(r-1.55) Fix 'soft line break' handling in convert.quoted-printable-decode
http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/filters.c?r1=1.44.2.5&r2=1.44.2.6&diff_format=u
Index: php-src/ext/standard/filters.c
diff -u php-src/ext/standard/filters.c:1.44.2.5
php-src/ext/standard/filters.c:1.44.2.6
--- php-src/ext/standard/filters.c:1.44.2.5 Wed Jan 18 23:55:47 2006
+++ php-src/ext/standard/filters.c Mon Apr 17 19:26:04 2006
@@ -20,7 +20,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: filters.c,v 1.44.2.5 2006/01/18 23:55:47 tony2001 Exp $ */
+/* $Id: filters.c,v 1.44.2.6 2006/04/17 19:26:04 pollita Exp $ */
#include "php.h"
#include "php_globals.h"
@@ -1031,6 +1031,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++;
@@ -1088,7 +1100,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;
@@ -1408,12 +1429,10 @@
size_t lbchars_len;
if (options != NULL) {
+ /* If line-break-chars are not specified,
filter will attempt to detect line endings (\r, \n, or \r\n) */
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) {
if
(php_conv_qprint_decode_ctor((php_conv_qprint_decode *)retval, lbchars,
lbchars_len, 1, persistent)) {
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php