summaryrefslogtreecommitdiffstats
path: root/app/models/attachment.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/attachment.rb')
-rw-r--r--app/models/attachment.rb6
1 files changed, 2 insertions, 4 deletions
diff --git a/app/models/attachment.rb b/app/models/attachment.rb
index 2dda3f353..09e4057cf 100644
--- a/app/models/attachment.rb
+++ b/app/models/attachment.rb
@@ -177,11 +177,9 @@ private
def sanitize_filename(value)
# get only the filename, not the whole path
just_filename = value.gsub(/^.*(\\|\/)/, '')
- # NOTE: File.basename doesn't work right with Windows paths on Unix
- # INCORRECT: just_filename = File.basename(value.gsub('\\\\', '/'))
- # Finally, replace all non alphanumeric, hyphens or periods with underscore
- @filename = just_filename.gsub(/[^\w\.\-]/,'_')
+ # Finally, replace invalid characters with underscore
+ @filename = just_filename.gsub(/[\/\?\%\*\:\|\"\'<>]+/, '_')
end
# Returns an ASCII or hashed filename