Skip to content

Commit

Permalink
Fixing some data consistency issues with plain-text and weird characters
Browse files Browse the repository at this point in the history
  • Loading branch information
Rican7 committed Jun 19, 2013
1 parent 7f56a73 commit 515fa8f
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/OneMightyRoar/PhpFileManager/FileObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,13 @@ public static function createFromBuffer($raw_binary_data, $name = null)
// Must have the fileinfo extension loaded to automatically detect the MIME type
}

// Only convert binary to hex if its not plain text
if (strpos($mime_type, 'text') !== 0 || static::isBase64String($raw_binary_data)) {
$raw_binary_data = bin2hex($raw_binary_data);
}

// Wrap our binary data in a SplFileObject compatible data stream
$stream_wrapped = 'data://'. $mime_type .','. bin2hex($raw_binary_data);
$stream_wrapped = 'data://'. $mime_type .','. rawurlencode($raw_binary_data);

$object = new static($stream_wrapped, 'r');
$object->setName($name);
Expand Down Expand Up @@ -716,8 +721,6 @@ public function getExtension($with_dot = false)

if (null !== $this->getName() && strpos($this->getName(), '.') !== false) {
$extension = substr(strrchr($this->getName(), '.'), 1);
} else {
$extension = parent::getExtension();
}

// Is our extension still "empty"?
Expand Down

0 comments on commit 515fa8f

Please sign in to comment.