svn: /pecl/mailparse/trunk/ mailparse.c
| From: | Remi Collet | Date: | Sun, 05 Apr 2015 07:18:13 +0000 |
| Subject: | svn: /pecl/mailparse/trunk/ mailparse.c | ||
| Groups: | php.pecl.cvs | ||
| Request: | Send a blank email to pecl-cvs+get-22018@lists.php.net to get a copy of this message | ||
remi Sun, 05 Apr 2015 07:18:13 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=336372
Log:
fix mailparse_uudecode_all (don't delete temp file), covered by 004.phpt
Changed paths:
U pecl/mailparse/trunk/mailparse.c
Modified: pecl/mailparse/trunk/mailparse.c
===================================================================
--- pecl/mailparse/trunk/mailparse.c 2015-04-05 06:36:38 UTC (rev 336371)
+++ pecl/mailparse/trunk/mailparse.c 2015-04-05 07:18:13 UTC (rev 336372)
@@ -754,7 +754,19 @@
return file_size;
}
+/* php_stream_fopen_temporary_file auto unlink the file on close
+ * this will keep the file
+ */
+static php_stream *_mailparse_create_stream(char **path) {
+ int fd;
+ fd = php_open_temporary_fd(NULL, "mailparse", path);
+ if (fd != -1) {
+ return php_stream_fopen_from_fd_rel(fd, "r+b", NULL);
+ }
+ return NULL;
+}
+
/* {{{ proto array mailparse_uudecode_all(resource fp)
Scans the data from fp and extract each embedded uuencoded file. Returns an array listing
filename information */
PHP_FUNCTION(mailparse_uudecode_all)
@@ -770,7 +782,7 @@
php_stream_from_zval(instream, &file);
- outstream = php_stream_fopen_temporary_file(NULL, "mailparse", &outpath);
+ outstream = _mailparse_create_stream(&outpath);
if (outstream == NULL) {
zend_error(E_WARNING, "%s(): unable to open temp file",
get_active_function_name(TSRMLS_C));
RETURN_FALSE;
@@ -810,7 +822,7 @@
add_assoc_string(item, "origfilename", origfilename, 1);
/* create a temp file for the data */
- partstream = php_stream_fopen_temporary_file(NULL, "mailparse", &outpath);
+ partstream = _mailparse_create_stream(&outpath);
if (partstream) {
nparts++;
add_assoc_string(item, "filename", outpath, 0);