From fa4341dcdff116be55081b5782e2c027b2421b9b Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Thu, 28 Mar 2002 00:43:44 +0000 Subject: [PATCH] make quoted-printable encoding safe for use with digital signatures. Added some tests --- ext/mailparse/mailparse.c | 42 +++++++++++++++++++++++++++------- ext/mailparse/tests/004.phpt | 44 ++++++++++++++++++++++++++++++++++++ ext/mailparse/tests/005.phpt | 40 ++++++++++++++++++++++++++++++++ 3 files changed, 118 insertions(+), 8 deletions(-) create mode 100644 ext/mailparse/tests/004.phpt create mode 100644 ext/mailparse/tests/005.phpt diff --git a/ext/mailparse/mailparse.c b/ext/mailparse/mailparse.c index 4a102e2831..ed8672c886 100755 --- a/ext/mailparse/mailparse.c +++ b/ext/mailparse/mailparse.c @@ -246,7 +246,7 @@ PHP_FUNCTION(mailparse_uudecode_all) } else { /* write to the output file */ - php_stream_puts(outstream, buffer); + php_stream_write_string(outstream, buffer); } } php_stream_close(outstream); @@ -438,13 +438,39 @@ PHP_FUNCTION(mailparse_stream_encode) deststream ); - while(!php_stream_eof(srcstream)) { - len = php_stream_read(srcstream, buf, bufsize); - if (len > 0) - { - int i; - for (i=0; i character + * in front of it and invalidate the content/signature */ + while(!php_stream_eof(srcstream)) { + if (NULL != php_stream_gets(srcstream, buf, bufsize)) { + int i; + + len = strlen(buf); + + if (strncmp(buf, "From ", 5) == 0) { + mbfl_convert_filter_flush(conv); + php_stream_write(deststream, "=46rom ", 7); + i = 5; + } else { + i = 0; + } + + for (; i 0) + { + int i; + for (i=0; i +--POST-- +--GET-- +--FILE-- + +--EXPECT-- +BODY +To: fred@bloggs.com + +hello, this is some text hello. +blah blah blah. + +UUE +this is a test diff --git a/ext/mailparse/tests/005.phpt b/ext/mailparse/tests/005.phpt new file mode 100644 index 0000000000..b67cef48dc --- /dev/null +++ b/ext/mailparse/tests/005.phpt @@ -0,0 +1,40 @@ +--TEST-- +Check quoted-printable encoding generates S/MIME safe content +--SKIPIF-- + +--POST-- +--GET-- +--FILE-- + +--EXPECT-- +To: fred@bloggs.com + +blah blah blah From blah $ " & =A3 blah blah blah blah blah +=46rom the first of the month, things will be different! +blah blah blah From blah +Frome is a town in Somerset. + -- 2.50.1