mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
Resolve #466
This commit is contained in:
parent
bb39d1709e
commit
d8a64124f2
5 changed files with 21 additions and 17 deletions
|
|
@ -1110,9 +1110,15 @@ class Actions
|
||||||
return $oAccount;
|
return $oAccount;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getDecodedRawKeyValue(string $sRawKey): array
|
protected function encodeRawKey(?Model\Account $oAccount, array $aValues): string
|
||||||
{
|
{
|
||||||
return empty($sRawKey) ? array() : Utils::DecodeKeyValuesQ($sRawKey);
|
return \SnappyMail\Crypt::EncryptUrlSafe($aValues, \sha1(APP_SALT . ($oAccount ? $oAccount->Hash() : '')));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function decodeRawKey(?Model\Account $oAccount, string $sRawKey): array
|
||||||
|
{
|
||||||
|
return empty($sRawKey) ? []
|
||||||
|
: (\SnappyMail\Crypt::DecryptUrlSafe($sRawKey, \sha1(APP_SALT . ($oAccount ? $oAccount->Hash() : ''))) ?: []);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function StaticCache(): string
|
public function StaticCache(): string
|
||||||
|
|
|
||||||
|
|
@ -107,8 +107,7 @@ trait Attachments
|
||||||
|
|
||||||
if (!$bError) {
|
if (!$bError) {
|
||||||
$mResult = array(
|
$mResult = array(
|
||||||
'FileHash' => Utils::EncodeKeyValuesQ(array(
|
'FileHash' => $this->encodeRawKey($oAccount, array(
|
||||||
'Account' => $oAccount ? $oAccount->Hash() : '',
|
|
||||||
'FileName' => ($sFolder ? 'messages' : 'attachments') . \date('-YmdHis') . '.zip',
|
'FileName' => ($sFolder ? 'messages' : 'attachments') . \date('-YmdHis') . '.zip',
|
||||||
'MimeType' => 'application/zip',
|
'MimeType' => 'application/zip',
|
||||||
'FileHash' => $sZipHash
|
'FileHash' => $sZipHash
|
||||||
|
|
@ -135,7 +134,7 @@ trait Attachments
|
||||||
|
|
||||||
private function getMimeFileByHash(\RainLoop\Model\Account $oAccount, string $sHash) : array
|
private function getMimeFileByHash(\RainLoop\Model\Account $oAccount, string $sHash) : array
|
||||||
{
|
{
|
||||||
$aValues = $this->getDecodedRawKeyValue($sHash);
|
$aValues = $this->decodeRawKey($oAccount, $sHash);
|
||||||
|
|
||||||
$sFolder = isset($aValues['Folder']) ? (string) $aValues['Folder'] : '';
|
$sFolder = isset($aValues['Folder']) ? (string) $aValues['Folder'] : '';
|
||||||
$iUid = isset($aValues['Uid']) ? (int) $aValues['Uid'] : 0;
|
$iUid = isset($aValues['Uid']) ? (int) $aValues['Uid'] : 0;
|
||||||
|
|
|
||||||
|
|
@ -566,7 +566,7 @@ trait Messages
|
||||||
$oFilesProvider = $this->FilesProvider();
|
$oFilesProvider = $this->FilesProvider();
|
||||||
foreach ($aAttachments as $mIndex => $sAttachment) {
|
foreach ($aAttachments as $mIndex => $sAttachment) {
|
||||||
$aAttachments[$mIndex] = false;
|
$aAttachments[$mIndex] = false;
|
||||||
if ($aValues = \RainLoop\Utils::DecodeKeyValuesQ($sAttachment)) {
|
if ($aValues = $this->encodeRawKey($oAccount, $sAttachment)) {
|
||||||
$sFolder = isset($aValues['Folder']) ? (string) $aValues['Folder'] : '';
|
$sFolder = isset($aValues['Folder']) ? (string) $aValues['Folder'] : '';
|
||||||
$iUid = isset($aValues['Uid']) ? (int) $aValues['Uid'] : 0;
|
$iUid = isset($aValues['Uid']) ? (int) $aValues['Uid'] : 0;
|
||||||
$sMimeIndex = isset($aValues['MimeIndex']) ? (string) $aValues['MimeIndex'] : '';
|
$sMimeIndex = isset($aValues['MimeIndex']) ? (string) $aValues['MimeIndex'] : '';
|
||||||
|
|
|
||||||
|
|
@ -9,10 +9,12 @@ trait Raw
|
||||||
*/
|
*/
|
||||||
public function RawViewAsPlain() : bool
|
public function RawViewAsPlain() : bool
|
||||||
{
|
{
|
||||||
$this->initMailClientConnection();
|
$oAccount = $this->initMailClientConnection();
|
||||||
|
|
||||||
$sRawKey = (string) $this->GetActionParam('RawKey', '');
|
$aValues = $this->decodeRawKey(
|
||||||
$aValues = $this->getDecodedRawKeyValue($sRawKey);
|
$oAccount,
|
||||||
|
(string) $this->GetActionParam('RawKey', '')
|
||||||
|
);
|
||||||
|
|
||||||
$sFolder = isset($aValues['Folder']) ? (string) $aValues['Folder'] : '';
|
$sFolder = isset($aValues['Folder']) ? (string) $aValues['Folder'] : '';
|
||||||
$iUid = isset($aValues['Uid']) ? (int) $aValues['Uid'] : 0;
|
$iUid = isset($aValues['Uid']) ? (int) $aValues['Uid'] : 0;
|
||||||
|
|
@ -113,7 +115,8 @@ trait Raw
|
||||||
{
|
{
|
||||||
$sRawKey = (string) $this->GetActionParam('RawKey', '');
|
$sRawKey = (string) $this->GetActionParam('RawKey', '');
|
||||||
|
|
||||||
$aValues = $this->getDecodedRawKeyValue($sRawKey);
|
$oAccount = $this->getAccountFromToken();
|
||||||
|
$aValues = $this->decodeRawKey($oAccount, $sRawKey);
|
||||||
|
|
||||||
$sRange = \MailSo\Base\Http::GetHeader('Range');
|
$sRange = \MailSo\Base\Http::GetHeader('Range');
|
||||||
|
|
||||||
|
|
@ -141,8 +144,6 @@ trait Raw
|
||||||
if (!empty($sFileHashIn)) {
|
if (!empty($sFileHashIn)) {
|
||||||
$this->verifyCacheByKey($sRawKey);
|
$this->verifyCacheByKey($sRawKey);
|
||||||
|
|
||||||
$oAccount = $this->getAccountFromToken();
|
|
||||||
|
|
||||||
// https://github.com/the-djmaze/snappymail/issues/144
|
// https://github.com/the-djmaze/snappymail/issues/144
|
||||||
if ('.pdf' === \substr($sFileNameIn,-4)) {
|
if ('.pdf' === \substr($sFileNameIn,-4)) {
|
||||||
$sContentTypeOut = 'application/pdf'; // application/octet-stream
|
$sContentTypeOut = 'application/pdf'; // application/octet-stream
|
||||||
|
|
@ -175,7 +176,7 @@ trait Raw
|
||||||
$this->verifyCacheByKey($sRawKey);
|
$this->verifyCacheByKey($sRawKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
$oAccount = $this->initMailClientConnection();
|
$this->initMailClientConnection();
|
||||||
|
|
||||||
$self = $this;
|
$self = $this;
|
||||||
return $this->MailClient()->MessageMimeStream(
|
return $this->MailClient()->MessageMimeStream(
|
||||||
|
|
|
||||||
|
|
@ -130,8 +130,7 @@ trait Response
|
||||||
|
|
||||||
$sSubject = $mResult['subject'];
|
$sSubject = $mResult['subject'];
|
||||||
$mResult['Hash'] = \md5($mResult['Folder'].$mResult['Uid']);
|
$mResult['Hash'] = \md5($mResult['Folder'].$mResult['Uid']);
|
||||||
$mResult['RequestHash'] = Utils::EncodeKeyValuesQ(array(
|
$mResult['RequestHash'] = $this->encodeRawKey($oAccount, array(
|
||||||
'Account' => $oAccount->Hash(),
|
|
||||||
'Folder' => $mResult['Folder'],
|
'Folder' => $mResult['Folder'],
|
||||||
'Uid' => $mResult['Uid'],
|
'Uid' => $mResult['Uid'],
|
||||||
'MimeType' => 'message/rfc822',
|
'MimeType' => 'message/rfc822',
|
||||||
|
|
@ -180,8 +179,7 @@ trait Response
|
||||||
if ($mResponse instanceof \MailSo\Mail\Attachment) {
|
if ($mResponse instanceof \MailSo\Mail\Attachment) {
|
||||||
$mResult = $mResponse->jsonSerialize();
|
$mResult = $mResponse->jsonSerialize();
|
||||||
$mResult['IsThumbnail'] = $this->GetCapa(Capa::ATTACHMENT_THUMBNAILS) && $this->isFileHasThumbnail($mResult['FileName']);
|
$mResult['IsThumbnail'] = $this->GetCapa(Capa::ATTACHMENT_THUMBNAILS) && $this->isFileHasThumbnail($mResult['FileName']);
|
||||||
$mResult['Download'] = Utils::EncodeKeyValuesQ(array(
|
$mResult['Download'] = $this->encodeRawKey($this->getAccountFromToken(), array(
|
||||||
'Account' => $this->getAccountFromToken()->Hash(),
|
|
||||||
'Folder' => $mResult['Folder'],
|
'Folder' => $mResult['Folder'],
|
||||||
'Uid' => $mResult['Uid'],
|
'Uid' => $mResult['Uid'],
|
||||||
'MimeIndex' => $mResult['MimeIndex'],
|
'MimeIndex' => $mResult['MimeIndex'],
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue