mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-07 16:37:02 +03:00
GPG allow TEMP stream_select
This commit is contained in:
parent
b17a405a81
commit
03b1a5521f
5 changed files with 19 additions and 119 deletions
|
|
@ -170,6 +170,11 @@ class Binary
|
||||||
return \fopen(self::STREAM_NAME.'://'.$sHashName, 'rb');
|
return \fopen(self::STREAM_NAME.'://'.$sHashName, 'rb');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function stream_cast(int $cast_as) /*: resource*/
|
||||||
|
{
|
||||||
|
return false; // $this->rStream;
|
||||||
|
}
|
||||||
|
|
||||||
public function stream_open(string $sPath) : bool
|
public function stream_open(string $sPath) : bool
|
||||||
{
|
{
|
||||||
$this->iPos = 0;
|
$this->iPos = 0;
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ class TempFile
|
||||||
/**
|
/**
|
||||||
* @var resource
|
* @var resource
|
||||||
*/
|
*/
|
||||||
private $rSream;
|
private $rStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return resource|bool
|
* @return resource|bool
|
||||||
|
|
@ -59,14 +59,14 @@ class TempFile
|
||||||
if (isset(self::$aStreams[$sHashName]) &&
|
if (isset(self::$aStreams[$sHashName]) &&
|
||||||
\is_resource(self::$aStreams[$sHashName]))
|
\is_resource(self::$aStreams[$sHashName]))
|
||||||
{
|
{
|
||||||
$this->rSream = self::$aStreams[$sHashName];
|
$this->rStream = self::$aStreams[$sHashName];
|
||||||
\fseek($this->rSream, 0);
|
\fseek($this->rStream, 0);
|
||||||
$bResult = true;
|
$bResult = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->rSream = \fopen('php://temp', 'r+b');
|
$this->rStream = \fopen('php://temp', 'r+b');
|
||||||
self::$aStreams[$sHashName] = $this->rSream;
|
self::$aStreams[$sHashName] = $this->rStream;
|
||||||
|
|
||||||
$bResult = true;
|
$bResult = true;
|
||||||
}
|
}
|
||||||
|
|
@ -82,37 +82,37 @@ class TempFile
|
||||||
|
|
||||||
public function stream_flush() : bool
|
public function stream_flush() : bool
|
||||||
{
|
{
|
||||||
return \fflush($this->rSream);
|
return \fflush($this->rStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function stream_read(int $iLen) : string
|
public function stream_read(int $iLen) : string
|
||||||
{
|
{
|
||||||
return \fread($this->rSream, $iLen);
|
return \fread($this->rStream, $iLen);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function stream_write(string $sInputString) : int
|
public function stream_write(string $sInputString) : int
|
||||||
{
|
{
|
||||||
return \fwrite($this->rSream, $sInputString);
|
return \fwrite($this->rStream, $sInputString);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function stream_tell() : int
|
public function stream_tell() : int
|
||||||
{
|
{
|
||||||
return \ftell($this->rSream);
|
return \ftell($this->rStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function stream_eof() : bool
|
public function stream_eof() : bool
|
||||||
{
|
{
|
||||||
return \feof($this->rSream);
|
return \feof($this->rStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function stream_stat() : array
|
public function stream_stat() : array
|
||||||
{
|
{
|
||||||
return \fstat($this->rSream);
|
return \fstat($this->rStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function stream_seek(int $iOffset, int $iWhence = SEEK_SET) : int
|
public function stream_seek(int $iOffset, int $iWhence = SEEK_SET) : int
|
||||||
{
|
{
|
||||||
return \fseek($this->rSream, $iOffset, $iWhence);
|
return \fseek($this->rStream, $iOffset, $iWhence);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,105 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of MailSo.
|
|
||||||
*
|
|
||||||
* (c) 2014 Usenko Timur
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace MailSo\Base\StreamWrappers;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @category MailSo
|
|
||||||
* @package Base
|
|
||||||
* @subpackage StreamWrappers
|
|
||||||
*/
|
|
||||||
class Test
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
const STREAM_NAME = 'mailsotest';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
private static $aStreams = array();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var resource
|
|
||||||
*/
|
|
||||||
private $rReadSream;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @return resource|bool
|
|
||||||
*/
|
|
||||||
public static function CreateStream(string $sRawResponse)
|
|
||||||
{
|
|
||||||
$sHashName = \md5(\microtime(true).\rand(1000, 9999));
|
|
||||||
|
|
||||||
$rConnect = \fopen('php://memory', 'r+b');
|
|
||||||
\fwrite($rConnect, $sRawResponse);
|
|
||||||
\fseek($rConnect, 0);
|
|
||||||
|
|
||||||
self::$aStreams[$sHashName] = $rConnect;
|
|
||||||
|
|
||||||
return \fopen(self::STREAM_NAME.'://'.$sHashName, 'r+b');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function stream_open(string $sPath) : bool
|
|
||||||
{
|
|
||||||
$bResult = false;
|
|
||||||
$aPath = \parse_url($sPath);
|
|
||||||
|
|
||||||
if (isset($aPath['host']) && isset($aPath['scheme']) &&
|
|
||||||
\strlen($aPath['host']) && \strlen($aPath['scheme']) &&
|
|
||||||
self::STREAM_NAME === $aPath['scheme'])
|
|
||||||
{
|
|
||||||
$sHashName = $aPath['host'];
|
|
||||||
if (isset(self::$aStreams[$sHashName]) &&
|
|
||||||
\is_resource(self::$aStreams[$sHashName]))
|
|
||||||
{
|
|
||||||
$this->rReadSream = self::$aStreams[$sHashName];
|
|
||||||
$bResult = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $bResult;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function stream_read(int $iCount) : string
|
|
||||||
{
|
|
||||||
return \fread($this->rReadSream, $iCount);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function stream_write(string $sInputString) : int
|
|
||||||
{
|
|
||||||
return \strlen($sInputString);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function stream_tell() : int
|
|
||||||
{
|
|
||||||
return \ftell($this->rReadSream);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function stream_eof() : bool
|
|
||||||
{
|
|
||||||
return \feof($this->rReadSream);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function stream_stat() : array
|
|
||||||
{
|
|
||||||
return \fstat($this->rReadSream);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function stream_seek() : bool
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
\stream_wrapper_register(Test::STREAM_NAME, '\\MailSo\\Base\\StreamWrappers\\Test');
|
|
||||||
|
|
@ -1288,7 +1288,6 @@ trait Messages
|
||||||
if ($sFingerprint) {
|
if ($sFingerprint) {
|
||||||
$GPG = $this->GnuPG();
|
$GPG = $this->GnuPG();
|
||||||
$oBody = $oMessage->GetRootPart();
|
$oBody = $oMessage->GetRootPart();
|
||||||
$fp = \fopen('php://temp', 'r+b');
|
|
||||||
$resource = $oBody->ToStream();
|
$resource = $oBody->ToStream();
|
||||||
$oBody->Body = null;
|
$oBody->Body = null;
|
||||||
$oBody->SubParts->Clear();
|
$oBody->SubParts->Clear();
|
||||||
|
|
@ -1296,6 +1295,7 @@ trait Messages
|
||||||
$oMessage->Attachments()->Clear();
|
$oMessage->Attachments()->Clear();
|
||||||
|
|
||||||
\MailSo\Base\StreamFilters\LineEndings::appendTo($resource);
|
\MailSo\Base\StreamFilters\LineEndings::appendTo($resource);
|
||||||
|
$fp = \fopen('php://temp', 'r+b');
|
||||||
\stream_copy_to_stream($resource, $fp);
|
\stream_copy_to_stream($resource, $fp);
|
||||||
$GPG->addSignKey($sFingerprint, $sPassphrase);
|
$GPG->addSignKey($sFingerprint, $sPassphrase);
|
||||||
$GPG->setsignmode(GNUPG_SIG_MODE_DETACH);
|
$GPG->setsignmode(GNUPG_SIG_MODE_DETACH);
|
||||||
|
|
|
||||||
|
|
@ -908,7 +908,7 @@ class GPG
|
||||||
// https://github.com/the-djmaze/snappymail/issues/331
|
// https://github.com/the-djmaze/snappymail/issues/331
|
||||||
// $meta['stream_type'] == MEMORY or $meta['wrapper_data'] == MailSo\Base\StreamWrappers\Literal
|
// $meta['stream_type'] == MEMORY or $meta['wrapper_data'] == MailSo\Base\StreamWrappers\Literal
|
||||||
$meta = \stream_get_meta_data($input);
|
$meta = \stream_get_meta_data($input);
|
||||||
if ('STDIO' != $meta['stream_type']) {
|
if (!\in_array($meta['stream_type'], ['STDIO', 'TEMP'])) {
|
||||||
/*
|
/*
|
||||||
$fp = \fopen('php://temp');
|
$fp = \fopen('php://temp');
|
||||||
\stream_copy_to_stream($input, $fp);
|
\stream_copy_to_stream($input, $fp);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue