Skip to content

Commit

Permalink
fix preg_replace patterns with dash
Browse files Browse the repository at this point in the history
  • Loading branch information
verot committed Apr 11, 2016
1 parent f1c6e3c commit e89285d
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/class.upload.php
Expand Up @@ -2344,8 +2344,8 @@ function upload($file, $lang = 'en_GB') {
finfo_close($f);
$this->file_src_mime = $mime;
$this->log .= '&nbsp;&nbsp;&nbsp;&nbsp;MIME type detected as ' . $this->file_src_mime . ' by Fileinfo PECL extension<br />';
if (preg_match("/^([\.\-\w]+)\/([\.\-\w]+)(.*)$/i", $this->file_src_mime)) {
$this->file_src_mime = preg_replace("/^([\.\-\w]+)\/([\.\-\w]+)(.*)$/i", '$1/$2', $this->file_src_mime);
if (preg_match("/^([\.\w-]+)\/([\.\w-]+)(.*)$/i", $this->file_src_mime)) {
$this->file_src_mime = preg_replace("/^([\.\w-]+)\/([\.\w-]+)(.*)$/i", '$1/$2', $this->file_src_mime);
$this->log .= '-&nbsp;MIME validated as ' . $this->file_src_mime . '<br />';
} else {
$this->file_src_mime = null;
Expand All @@ -2358,8 +2358,8 @@ function upload($file, $lang = 'en_GB') {
if ($f) {
$this->file_src_mime = $f->file(realpath($this->file_src_pathname));
$this->log .= '- MIME type detected as ' . $this->file_src_mime . ' by Fileinfo PECL extension<br />';
if (preg_match("/^([\.\-\w]+)\/([\.\-\w]+)(.*)$/i", $this->file_src_mime)) {
$this->file_src_mime = preg_replace("/^([\.\-\w]+)\/([\.\-\w]+)(.*)$/i", '$1/$2', $this->file_src_mime);
if (preg_match("/^([\.\w-]+)\/([\.\w-]+)(.*)$/i", $this->file_src_mime)) {
$this->file_src_mime = preg_replace("/^([\.\w-]+)\/([\.\w-]+)(.*)$/i", '$1/$2', $this->file_src_mime);
$this->log .= '-&nbsp;MIME validated as ' . $this->file_src_mime . '<br />';
} else {
$this->file_src_mime = null;
Expand All @@ -2384,8 +2384,8 @@ function upload($file, $lang = 'en_GB') {
if (strlen($mime = @exec("file -bi ".escapeshellarg($this->file_src_pathname))) != 0) {
$this->file_src_mime = trim($mime);
$this->log .= '&nbsp;&nbsp;&nbsp;&nbsp;MIME type detected as ' . $this->file_src_mime . ' by UNIX file() command<br />';
if (preg_match("/^([\.\-\w]+)\/([\.\-\w]+)(.*)$/i", $this->file_src_mime)) {
$this->file_src_mime = preg_replace("/^([\.\-\w]+)\/([\.\-\w]+)(.*)$/i", '$1/$2', $this->file_src_mime);
if (preg_match("/^([\.\w-]+)\/([\.\w-]+)(.*)$/i", $this->file_src_mime)) {
$this->file_src_mime = preg_replace("/^([\.\w-]+)\/([\.\w-]+)(.*)$/i", '$1/$2', $this->file_src_mime);
$this->log .= '-&nbsp;MIME validated as ' . $this->file_src_mime . '<br />';
} else {
$this->file_src_mime = null;
Expand All @@ -2411,8 +2411,8 @@ function upload($file, $lang = 'en_GB') {
if (function_exists('mime_content_type')) {
$this->file_src_mime = mime_content_type($this->file_src_pathname);
$this->log .= '&nbsp;&nbsp;&nbsp;&nbsp;MIME type detected as ' . $this->file_src_mime . ' by mime_content_type()<br />';
if (preg_match("/^([\.\-\w]+)\/([\.\-\w]+)(.*)$/i", $this->file_src_mime)) {
$this->file_src_mime = preg_replace("/^([\.\-\w]+)\/([\.\-\w]+)(.*)$/i", '$1/$2', $this->file_src_mime);
if (preg_match("/^([\.\w-]+)\/([\.\w-]+)(.*)$/i", $this->file_src_mime)) {
$this->file_src_mime = preg_replace("/^([\.\w-]+)\/([\.\w-]+)(.*)$/i", '$1/$2', $this->file_src_mime);
$this->log .= '-&nbsp;MIME validated as ' . $this->file_src_mime . '<br />';
} else {
$this->file_src_mime = null;
Expand All @@ -2438,8 +2438,8 @@ function upload($file, $lang = 'en_GB') {
$this->file_src_mime = ($mime==IMAGETYPE_GIF ? 'image/gif' : ($mime==IMAGETYPE_JPEG ? 'image/jpeg' : ($mime==IMAGETYPE_PNG ? 'image/png' : ($mime==IMAGETYPE_BMP ? 'image/bmp' : null))));
}
$this->log .= '&nbsp;&nbsp;&nbsp;&nbsp;MIME type detected as ' . $this->file_src_mime . ' by PHP getimagesize() function<br />';
if (preg_match("/^([\.\-\w]+)\/([\.\-\w]+)(.*)$/i", $this->file_src_mime)) {
$this->file_src_mime = preg_replace("/^([\.\-\w]+)\/([\.\-\w]+)(.*)$/i", '$1/$2', $this->file_src_mime);
if (preg_match("/^([\.\w-]+)\/([\.\w-]+)(.*)$/i", $this->file_src_mime)) {
$this->file_src_mime = preg_replace("/^([\.\w-]+)\/([\.\w-]+)(.*)$/i", '$1/$2', $this->file_src_mime);
$this->log .= '-&nbsp;MIME validated as ' . $this->file_src_mime . '<br />';
} else {
$this->file_src_mime = null;
Expand All @@ -2456,8 +2456,8 @@ function upload($file, $lang = 'en_GB') {
if (!empty($mime_from_browser) && !$this->file_src_mime || !is_string($this->file_src_mime) || empty($this->file_src_mime)) {
$this->file_src_mime =$mime_from_browser;
$this->log .= '- MIME type detected as ' . $this->file_src_mime . ' by browser<br />';
if (preg_match("/^([\.\-\w]+)\/([\.\-\w]+)(.*)$/i", $this->file_src_mime)) {
$this->file_src_mime = preg_replace("/^([\.\-\w]+)\/([\.\-\w]+)(.*)$/i", '$1/$2', $this->file_src_mime);
if (preg_match("/^([\.\w-]+)\/([\.\w-]+)(.*)$/i", $this->file_src_mime)) {
$this->file_src_mime = preg_replace("/^([\.\w-]+)\/([\.\w-]+)(.*)$/i", '$1/$2', $this->file_src_mime);
$this->log .= '-&nbsp;MIME validated as ' . $this->file_src_mime . '<br />';
} else {
$this->file_src_mime = null;
Expand Down

0 comments on commit e89285d

Please sign in to comment.