%PDF-1.5 %���� ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµùÕ5sLOšuY
| Server IP : 14.207.165.8 / Your IP : 216.73.216.26 Web Server : Apache/2.4.18 (Ubuntu) System : Linux 246 4.4.0-210-generic #242-Ubuntu SMP Fri Apr 16 09:57:56 UTC 2021 x86_64 User : root ( 0) PHP Version : 7.0.33-0ubuntu0.16.04.16 Disable Function : exec,passthru,shell_exec,system,proc_open,popen,pcntl_exec MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/html/ppaobm/vendor/swiftmailer/swiftmailer/tests/bug/Swift/ |
Upload File : |
<?php
class Swift_Bug76Test extends \PHPUnit\Framework\TestCase
{
private $inputFile;
private $outputFile;
private $encoder;
protected function setUp()
{
$this->inputFile = sys_get_temp_dir().'/in.bin';
file_put_contents($this->inputFile, '');
$this->outputFile = sys_get_temp_dir().'/out.bin';
file_put_contents($this->outputFile, '');
$this->encoder = $this->createEncoder();
}
protected function tearDown()
{
unlink($this->inputFile);
unlink($this->outputFile);
}
public function testBase64EncodedLineLengthNeverExceeds76CharactersEvenIfArgsDo()
{
$this->fillFileWithRandomBytes(1000, $this->inputFile);
$os = $this->createStream($this->inputFile);
$is = $this->createStream($this->outputFile);
$this->encoder->encodeByteStream($os, $is, 0, 80); //Exceeds 76
$this->assertMaxLineLength(76, $this->outputFile,
'%s: Line length should not exceed 76 characters'
);
}
public function assertMaxLineLength($length, $filePath, $message = '%s')
{
$lines = file($filePath);
foreach ($lines as $line) {
$this->assertTrue((strlen(trim($line)) <= 76), $message);
}
}
private function fillFileWithRandomBytes($byteCount, $file)
{
// I was going to use dd with if=/dev/random but this way seems more
// cross platform even if a hella expensive!!
file_put_contents($file, '');
$fp = fopen($file, 'wb');
for ($i = 0; $i < $byteCount; ++$i) {
$byteVal = random_int(0, 255);
fwrite($fp, pack('i', $byteVal));
}
fclose($fp);
}
private function createEncoder()
{
return new Swift_Mime_ContentEncoder_Base64ContentEncoder();
}
private function createStream($file)
{
return new Swift_ByteStream_FileByteStream($file, true);
}
}