}
else {
/* write to the output file */
- php_stream_puts(outstream, buffer);
+ php_stream_write_string(outstream, buffer);
}
}
php_stream_close(outstream);
deststream
);
- while(!php_stream_eof(srcstream)) {
- len = php_stream_read(srcstream, buf, bufsize);
- if (len > 0)
- {
- int i;
- for (i=0; i<len; i++)
- mbfl_convert_filter_feed(buf[i], conv);
+ if (enc == mbfl_no_encoding_qprint) {
+ /* If the qp encoded section is going to be digitally signed,
+ * it is a good idea to make sure that lines that begin "From "
+ * have the letter F encoded, so that MTAs do not stick a > 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<len; i++)
+ mbfl_convert_filter_feed(buf[i], conv);
+ }
+ }
+
+ } else {
+ while(!php_stream_eof(srcstream)) {
+ len = php_stream_read(srcstream, buf, bufsize);
+ if (len > 0)
+ {
+ int i;
+ for (i=0; i<len; i++)
+ mbfl_convert_filter_feed(buf[i], conv);
+ }
}
}
--- /dev/null
+--TEST--
+Check uudecode_all
+--SKIPIF--
+<?php if (!extension_loaded("mailparse")) print "skip"; ?>
+--POST--
+--GET--
+--FILE--
+<?php
+$text = <<<EOD
+To: fred@bloggs.com
+
+hello, this is some text hello.
+blah blah blah.
+
+begin 644 test.txt
+/=&AI<R!I<R!A('1E<W0*
+`
+end
+
+EOD;
+
+$fp = tmpfile();
+fwrite($fp, $text);
+
+$data = mailparse_uudecode_all($fp);
+
+echo "BODY\n";
+readfile($data[0]["filename"]);
+echo "UUE\n";
+readfile($data[1]["filename"]);
+
+unlink($data[0]["filename"]);
+unlink($data[1]["filename"]);
+
+?>
+--EXPECT--
+BODY
+To: fred@bloggs.com
+
+hello, this is some text hello.
+blah blah blah.
+
+UUE
+this is a test
--- /dev/null
+--TEST--
+Check quoted-printable encoding generates S/MIME safe content
+--SKIPIF--
+<?php if (!extension_loaded("mailparse")) print "skip"; ?>
+--POST--
+--GET--
+--FILE--
+<?php
+$text = <<<EOD
+To: fred@bloggs.com
+
+blah blah blah From blah $ " & £ blah blah blah blah blah
+From the first of the month, things will be different!
+blah blah blah From blah
+Frome is a town in Somerset.
+EOD;
+
+$fp = tmpfile();
+fwrite($fp, $text);
+rewind($fp);
+
+$fpdest = tmpfile();
+
+mailparse_stream_encode($fp, $fpdest, "quoted-printable");
+
+rewind($fpdest);
+
+fpassthru($fpdest);
+
+fclose($fp);
+fclose($fpdest);
+?>
+--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.
+