[PECL-CVS] [pecl-mail-mailparse] master: Fix MimeMessage::extract_uue() ignoring index greater than zero
[email protected] (Ilia Alshanetsky via Remi Collet) Wed, 24 Jun 2026 08:19:28 +0000
| Newsgroups | php.pecl.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: Ilia Alshanetsky (iliaal)
Committer: Remi Collet (remicollet)
Date: 2026-06-24T10:17:34+02:00
Commit: https://github.com/php/pecl-mail-mailparse/commit/5e9560010c277b8df408f6956ea5486904cb7d3e
Raw diff: https://github.com/php/pecl-mail-mailparse/commit/5e9560010c277b8df408f6956ea5486904cb7d3e.diff
Fix MimeMessage::extract_uue() ignoring index greater than zero
Changed paths:
A tests/extract_uue_multiple_parts.phpt
M mailparse.c
Diff:
diff --git a/mailparse.c b/mailparse.c
index b6f973b..055fc6f 100644
--- a/mailparse.c
+++ b/mailparse.c
@@ -559,6 +559,7 @@ PHP_METHOD(mimemessage, extract_uue)
} else {
/* skip that part */
mailparse_do_uudecode(srcstream, NULL);
+ nparts++;
}
} else {
if (php_stream_tell(srcstream) >= end)
diff --git a/tests/extract_uue_multiple_parts.phpt b/tests/extract_uue_multiple_parts.phpt
new file mode 100644
index 0000000..4b414ff
--- /dev/null
+++ b/tests/extract_uue_multiple_parts.phpt
@@ -0,0 +1,26 @@
+--TEST--
+MimeMessage::extract_uue() can extract uuencoded parts past the first
+--SKIPIF--
+<?php if (!extension_loaded("mailparse")) print "skip"; ?>
+--FILE--
+<?php
+/* extract_uue() compared a part counter that it never incremented, so any
+ * index greater than 0 returned NULL even when the part existed. */
+function uue($name, $data) {
+ return "begin 644 $name\n" . convert_uuencode($data) . "end\n\n";
+}
+$body = "intro line\n\n" . uue("a.txt", "FIRST") . "\n" . uue("b.txt", "SECOND");
+
+$fp = fopen("php://memory", "r+");
+fwrite($fp, $body);
+rewind($fp);
+$m = new MimeMessage("stream", $fp);
+var_dump($m->extract_uue(0, MAILPARSE_EXTRACT_RETURN));
+var_dump($m->extract_uue(1, MAILPARSE_EXTRACT_RETURN));
+var_dump($m->extract_uue(2, MAILPARSE_EXTRACT_RETURN));
+fclose($fp);
+?>
+--EXPECT--
+string(5) "FIRST"
+string(6) "SECOND"
+NULL