Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Changed _prep_filename() behaviour of Upload library #1385

Closed
wants to merge 5 commits into from

2 participants

@palicao

See issue #1380

palicao added some commits
@palicao palicao Revert 96db8f91c34c18119548cacc4692362f51e70407^..HEAD 3e1fadb
@palicao palicao Revert "Revert 96db8f91c34c18119548cacc4692362f51e70407^..HEAD"
This reverts commit 3e1fadbbf5f2f4bfd77db053c75e531cdd813ed2.
e223448
@palicao palicao Merge https://github.com/EllisLab/CodeIgniter into develop 77384af
@palicao palicao Update system/libraries/Upload.php b853f42
@palicao palicao Changed strange _prep_filename() behaviour of Upload library
Added $config['convert_dots'] parameter in configuration. Allows you to
decide if you want to replace all the dots, except the last one, in an
uploaded file name with underscores or leave it unchanged.
Fixes issue #1380.
0eb5a66
@palicao palicao closed this
@palicao palicao reopened this
@narfbg
Owner
@narfbg narfbg closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 19, 2012
  1. @palicao
  2. @palicao

    Revert "Revert 96db8f91c34c18119548cacc4692362f51e70407^..HEAD"

    palicao authored
    This reverts commit 3e1fadbbf5f2f4bfd77db053c75e531cdd813ed2.
Commits on May 22, 2012
  1. @palicao
Commits on May 23, 2012
  1. @palicao
  2. @palicao

    Changed strange _prep_filename() behaviour of Upload library

    palicao authored
    Added $config['convert_dots'] parameter in configuration. Allows you to
    decide if you want to replace all the dots, except the last one, in an
    uploaded file name with underscores or leave it unchanged.
    Fixes issue #1380.
This page is out of date. Refresh to see the latest.
Showing with 10 additions and 14 deletions.
  1. +10 −14 system/libraries/Upload.php
View
24 system/libraries/Upload.php
@@ -62,6 +62,7 @@ class CI_Upload {
public $xss_clean = FALSE;
public $temp_prefix = 'temp_file_';
public $client_name = '';
+ public $convert_dots = TRUE;
protected $_file_name_override = '';
@@ -117,7 +118,8 @@ public function initialize($config = array())
'remove_spaces' => TRUE,
'xss_clean' => FALSE,
'temp_prefix' => 'temp_file_',
- 'client_name' => ''
+ 'client_name' => '',
+ 'convert_dots' => TRUE
);
@@ -958,25 +960,19 @@ public function mimes_types($mime)
*/
protected function _prep_filename($filename)
{
- if (strpos($filename, '.') === FALSE OR $this->allowed_types == '*')
+ if (strpos($filename, '.') === FALSE)
{
return $filename;
}
-
+
$parts = explode('.', $filename);
$ext = array_pop($parts);
- $filename = array_shift($parts);
-
- foreach ($parts as $part)
+
+ if ($this->convert_dots === TRUE)
{
- if ( ! in_array(strtolower($part), $this->allowed_types) OR $this->mimes_types(strtolower($part)) === FALSE)
- {
- $filename .= '.'.$part.'_';
- }
- else
- {
- $filename .= '.'.$part;
- }
+ $filename = implode('_', $parts);
+ } else {
+ $filename = implode('.', $parts);
}
return $filename.'.'.$ext;
Something went wrong with that request. Please try again.