Got questions, comments, patches, etc.?
Contact Jason Woofenden
gitweb
/
wfpl.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
eb26817
)
upload.php cleanup: really don't make dot files
author
Jason Woofenden
<jason@jasonwoof.com>
Tue, 3 Nov 2015 03:13:12 +0000
(22:13 -0500)
committer
Jason Woofenden
<jason@jasonwoof.com>
Tue, 3 Nov 2015 03:13:19 +0000
(22:13 -0500)
upload.php
patch
|
blob
|
history
diff --git
a/upload.php
b/upload.php
index
4d81804
..
2509a6b
100644
(file)
--- a/
upload.php
+++ b/
upload.php
@@
-103,11
+103,17
@@
function generate_filename($path, $mime = 'text/plain') {
# replace symbols with underscores
$filename = preg_replace('|[^a-z0-9_.]|', '_', $filename);
# replace symbols with underscores
$filename = preg_replace('|[^a-z0-9_.]|', '_', $filename);
+ # limit length
+ if(strlen($filename > 80)) {
+ $filename = substr($filename, -80);
+ }
+
# remove dots from the beginning (no invisible files)
$filename = preg_replace('|^\.*|', '', $filename);
# remove dots from the beginning (no invisible files)
$filename = preg_replace('|^\.*|', '', $filename);
- if(strlen($filename > 80)) {
- $filename = substr($filename, -80);
+ # make sure there's something before the extension
+ if ($filename == '') {
+ return '_';
}
# fix extension
}
# fix extension
@@
-127,6
+133,7
@@
function generate_filename($path, $mime = 'text/plain') {
}
$filename = $basename . '.' . $ext;
}
}
$filename = $basename . '.' . $ext;
}
+
return $filename;
}
return $filename;
}