Skip to content

Commit

Permalink
Fix Psalm issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Plakhotnikov Vladimir committed Jun 29, 2024
1 parent b2a1bc0 commit 08171f6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Support/Stream/Base64DecodeFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function filter($in, $out, &$consumed, bool $closing): int
}

// Decode part of the data
$bucket->data = \base64_decode($this->buffer . \substr($bucket->data, 0, -$d));
$bucket->data = \base64_decode($this->buffer . \substr($bucket->data, 0, -$d), true);
$consumed += $bucket->datalen;
$this->buffer = \substr($bucket->data, -$d);

Expand Down
5 changes: 4 additions & 1 deletion src/Traffic/Parser/Http.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Buggregator\Trap\Traffic\Parser;

use Buggregator\Trap\Support\Stream\Base64DecodeFilter;
use Buggregator\Trap\Support\StreamHelper;
use Buggregator\Trap\Traffic\Message\Multipart\Field;
use Buggregator\Trap\Traffic\Message\Multipart\File;
Expand Down Expand Up @@ -111,7 +112,9 @@ public static function parseMultipartBody(StreamInterface $stream, string $bound
$writeFilters = [];
if ($part->hasHeader('Content-Transfer-Encoding')) {
$encoding = $part->getHeaderLine('Content-Transfer-Encoding');
$encoding === 'base64' and $writeFilters[] = \Buggregator\Trap\Support\Stream\Base64DecodeFilter::FILTER_NAME;
if ($encoding === 'base64') {
$writeFilters[] = Base64DecodeFilter::FILTER_NAME;
}
}

$fileStream = StreamHelper::createFileStream(writeFilters: $writeFilters);
Expand Down

0 comments on commit 08171f6

Please sign in to comment.