Skip to content

Commit

Permalink
Address the uploads issue gollum#1584
Browse files Browse the repository at this point in the history
'%20' in filenames are translated back to ' ' in both editor and file creation.
  • Loading branch information
heavywatal committed Jul 12, 2020
1 parent b32dcfa commit 5f5730f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
13 changes: 7 additions & 6 deletions lib/gollum/app.rb
Expand Up @@ -230,14 +230,15 @@ class App < Sinatra::Base
halt 500 unless tempfile.is_a? Tempfile

if wiki.per_page_uploads
# remove base_url and gollum/* subpath if necessary
dir = request.referer.
sub(request.base_url, '').
sub(/.*gollum\/[-\w]+\//, '')
dir = request.referer.sub(request.base_url, '')
# remove base path if it is set
dir = dir.sub(wiki.base_path, '') if wiki.base_path
dir.sub!(/^#{wiki.base_path}/, '') if wiki.base_path
# remove base_url and gollum/* subpath if necessary
dir.sub!(/^\/gollum\/[-\w]+\//, '')
# remove file extension
dir = dir.sub(::File.extname(dir), '')
dir.sub!(/#{::File.extname(dir)}$/, '')
# revert escaped whitespaces
dir.gsub!(/%20/, ' ')
dir = ::File.join('uploads', dir)
else
# store all uploads together
Expand Down
Expand Up @@ -299,6 +299,7 @@
var ext = file.name.split('.').pop().toLowerCase()
var image_ext = ['jpg', 'jpeg', 'tif', 'tiff', 'png', 'gif', 'svg', 'bmp']
// Link directly to image files
uploadDest = uploadDest.replace(/%20/g, ' ');
if ((image_ext.indexOf(ext) > -1)) {
var text = '[[/' + uploadDest + '/' + file.name + ']]';
} else {
Expand Down

0 comments on commit 5f5730f

Please sign in to comment.