Server IP : 127.0.0.2 / Your IP : 18.216.60.85 Web Server : Apache/2.4.18 (Ubuntu) System : User : www-data ( ) PHP Version : 7.0.33-0ubuntu0.16.04.16 Disable Function : disk_free_space,disk_total_space,diskfreespace,dl,exec,fpaththru,getmyuid,getmypid,highlight_file,ignore_user_abord,leak,listen,link,opcache_get_configuration,opcache_get_status,passthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,php_uname,phpinfo,posix_ctermid,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix,_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_times,posix_ttyname,posix_uname,pclose,popen,proc_open,proc_close,proc_get_status,proc_nice,proc_terminate,shell_exec,source,show_source,system,virtual MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/html/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 = rand(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); } }