예제 #1
0
 public function testUudecode()
 {
     $data = Horde_Mime::uudecode(file_get_contents(__DIR__ . '/fixtures/uudecode.txt'));
     $this->assertEquals(2, count($data));
     $this->assertArrayHasKey('data', $data[0]);
     $this->assertEquals('Test string', $data[0]['data']);
     $this->assertArrayHasKey('name', $data[0]);
     $this->assertEquals('test.txt', $data[0]['name']);
     $this->assertArrayHasKey('perm', $data[0]);
     $this->assertEquals('644', $data[0]['perm']);
     $this->assertArrayHasKey('data', $data[1]);
     $this->assertEquals('2nd string', $data[1]['data']);
     $this->assertArrayHasKey('name', $data[1]);
     $this->assertEquals('test2.txt', $data[1]['name']);
     $this->assertArrayHasKey('perm', $data[1]);
     $this->assertEquals('755', $data[1]['perm']);
 }
예제 #2
0
파일: Plain.php 프로젝트: DSNS-LAB/Dmail
 /**
  * Scan text for UUencode data an, if it exists, convert the part to the
  * embedded MIME representation.
  *
  * @return mixed  See self::_getEmbeddedMimeParts().
  */
 protected function _parseUUencode()
 {
     $text = Horde_String::convertCharset($this->_mimepart->getContents(), $this->_mimepart->getCharset(), 'UTF-8');
     $files = Horde_Mime::uudecode($text);
     if (empty($files)) {
         return null;
     }
     $new_part = new Horde_Mime_Part();
     $new_part->setType('multipart/mixed');
     $text_part = new Horde_Mime_Part();
     $text_part->setType('text/plain');
     $text_part->setCharset($this->getConfigParam('charset'));
     $text_part->setContents(preg_replace("/begin [0-7]{3} .+\r?\n.+\r?\nend/Us", "\n", $text));
     $new_part->addPart($text_part);
     reset($files);
     while (list(, $file) = each($files)) {
         $uupart = new Horde_Mime_Part();
         $uupart->setType('application/octet-stream');
         $uupart->setContents($file['data']);
         $uupart->setName(strip_tags($file['name']));
         $new_part->addPart($uupart);
     }
     return $new_part;
 }
예제 #3
0
파일: Part.php 프로젝트: x59/horde-mime
 /**
  * Decodes the contents of the part to binary encoding.
  *
  * @param resource $fp      A stream containing the data to decode.
  * @param string $encoding  The original file encoding.
  *
  * @return resource  A new file resource with the decoded data.
  */
 protected function _transferDecode($fp, $encoding)
 {
     /* If the contents are empty, return now. */
     fseek($fp, 0, SEEK_END);
     if (ftell($fp)) {
         switch ($encoding) {
             case 'base64':
                 try {
                     return $this->_writeStream($fp, array('error' => true, 'filter' => array('convert.base64-decode' => array())));
                 } catch (ErrorException $e) {
                 }
                 rewind($fp);
                 return $this->_writeStream(base64_decode(stream_get_contents($fp)));
             case 'quoted-printable':
                 try {
                     return $this->_writeStream($fp, array('error' => true, 'filter' => array('convert.quoted-printable-decode' => array())));
                 } catch (ErrorException $e) {
                 }
                 // Workaround for Horde Bug #8747
                 rewind($fp);
                 return $this->_writeStream(quoted_printable_decode(stream_get_contents($fp)));
             case 'uuencode':
             case 'x-uuencode':
             case 'x-uue':
                 /* Support for uuencoded encoding - although not required by
                  * RFCs, some mailers may still encode this way. */
                 $res = Horde_Mime::uudecode($this->_readStream($fp));
                 return $this->_writeStream($res[0]['data']);
         }
     }
     return $fp;
 }