Dots in a filenames fix
This commit is contained in:
parent
8a838e0e03
commit
8f19c5ecab
|
@ -173,13 +173,21 @@ class Mapper
|
||||||
$pathElements = explode('/', $path);
|
$pathElements = explode('/', $path);
|
||||||
$sluggedElements = array();
|
$sluggedElements = array();
|
||||||
|
|
||||||
// rip off the extension ext from last element
|
|
||||||
$last= end($pathElements);
|
$last= end($pathElements);
|
||||||
$parts = pathinfo($last);
|
$parts = pathinfo($last);
|
||||||
|
|
||||||
|
if ((preg_match('~[-\w]+~', $parts['filename'])) && (preg_match('~[-\w]+~', $parts['extension']))){
|
||||||
|
|
||||||
|
// rip off the extension ext from last element
|
||||||
$filename = $parts['filename'];
|
$filename = $parts['filename'];
|
||||||
array_pop($pathElements);
|
array_pop($pathElements);
|
||||||
array_push($pathElements, $filename);
|
array_push($pathElements, $filename);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
unset($parts['extension']);
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($pathElements as $pathElement) {
|
foreach ($pathElements as $pathElement) {
|
||||||
// remove empty elements
|
// remove empty elements
|
||||||
if (empty($pathElement)) {
|
if (empty($pathElement)) {
|
||||||
|
@ -213,8 +221,8 @@ class Mapper
|
||||||
*/
|
*/
|
||||||
private function slugify($text)
|
private function slugify($text)
|
||||||
{
|
{
|
||||||
// replace non letter or digits by -
|
// replace non letter or digits or dots by -
|
||||||
$text = preg_replace('~[^\\pL\d]+~u', '-', $text);
|
$text = preg_replace('~[^\\pL\d\.]+~u', '-', $text);
|
||||||
|
|
||||||
// trim
|
// trim
|
||||||
$text = trim($text, '-');
|
$text = trim($text, '-');
|
||||||
|
@ -228,7 +236,10 @@ class Mapper
|
||||||
$text = strtolower($text);
|
$text = strtolower($text);
|
||||||
|
|
||||||
// remove unwanted characters
|
// remove unwanted characters
|
||||||
$text = preg_replace('~[^-\w]+~', '', $text);
|
$text = preg_replace('~[^-\w\.]+~', '', $text);
|
||||||
|
|
||||||
|
// trim ending dots (for security reasons and win compatibility)
|
||||||
|
$text = preg_replace('~\.+$~', '', $text);
|
||||||
|
|
||||||
if (empty($text)) {
|
if (empty($text)) {
|
||||||
return uniqid();
|
return uniqid();
|
||||||
|
|
Loading…
Reference in New Issue