Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error fetching images uploaded through the editor when the path contains spaces #1584

Closed
acavalin opened this issue Jun 25, 2020 · 2 comments

Comments

@acavalin
Copy link

Describe the bug
Uploaded image is not displayed because gollum can't find it and redirects to "create new page".

To Reproduce
Steps to reproduce the behavior:

  1. Create a new page with spaces /hello world/foo bar.md and save it
  2. Edit the page, drag&drop an image with spaces jon doe.png, save
  3. Viewing the page you can see a broken picture
  4. Copy image location and paste link in a new browser tab
  5. You are being redirected to the creation of a new page

Expected behavior
When an image is uploaded, it has to be downloadable and thus viewable.

Screenshots
sshot

The page:

nice page [[/uploads/hello%20world/foo%20bar/jon doe.png]]
  • Image location: /uploads/hello%20world/foo%20bar/jon%20doe.png
  • Redirected to: /gollum/create/uploads/hello world/foo bar/jon doe.png

Environment Info

# $GEM_HOME/bin/gollum --version
Gollum 5.0.1

# ruby -v
ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-linux]

# start command
thin start --ssl --ssl-key-file /app/ssl.key --ssl-cert-file /app/ssl.crt -p $APP_PORT -R /app/config.ru
# config.ru
#!/usr/bin/env ruby
%w{ rubygems digest yaml gollum/app rack/ssl }.each{|l| require l }

USERS = YAML.load_file '/app/users.yml'
PASS  = USERS['default_password']

use Rack::SSL # force ssl

use Rack::Auth::Basic, "Accesso riservato" do |user, pass|
  Precious::App.set :logged_user, user if USERS.keys.include?(user.strip) && Digest::MD5.hexdigest(pass) == PASS
end

Precious::App.set :port          , ENV['APP_PORT'].to_i
Precious::App.set :gollum_path   , ENV['APP_DATA']
Precious::App.set :default_markup, :markdown
Precious::App.set :wiki_options  , {
  allow_editing:    true,       # --no-edit
  allow_uploads:    true,       # --allow-uploads
  critic_markup:    true,       # --critic-markup
  css:              true,       # --css => uses commited /custom.css
  emoji:            true,       # --emoji
  h1_title:         true,       # --h1-title
  js:               true,       # --js => uses commited /custom.js
  live_preview:     true,       # --live-preview
  mathjax:          true,       # --mathjax
  per_page_uploads: true,       # --allow-uploads page only if :allow_uploads is set too
  universal_toc:    false,      # https://github.com/gollum/gollum/wiki#table-of-contents-toc-tag
  user_icons:       'gravatar', # --user-icons
}

run Precious::App

class Precious::App
  before do # set author name/email
    # https://api.rubyonrails.org/classes/Hash.html#method-i-symbolize_keys
    session['gollum.author'] = USERS[settings.logged_user].transform_keys{|k| k.to_sym rescue k }
  end
end
# gem list
backports (3.17.2)
benchmark (default: 0.1.0)
bigdecimal (default: 2.0.0)
bundler (default: 2.1.4)
cgi (default: 0.1.0)
charlock_holmes (0.7.7)
commonmarker (0.21.0)
concurrent-ruby (1.1.6)
crass (1.0.6)
csv (default: 3.1.2)
daemons (1.3.1)
date (default: 3.0.0)
dbm (default: 1.1.0)
delegate (default: 0.1.0)
did_you_mean (default: 1.4.0)
escape_utils (1.2.1)
etc (default: 1.1.0)
eventmachine (1.2.7)
execjs (2.7.0)
fcntl (default: 1.0.0)
ffi (1.13.1)
fiddle (default: 1.0.0)
fileutils (default: 1.4.1)
forwardable (default: 1.3.1)
gdbm (default: 2.1.0)
gemojione (4.3.3)
getoptlong (default: 0.1.0)
github-linguist (7.9.0)
github-markup (3.0.4)
gollum (5.0.1)
gollum-lib (5.0.4)
gollum-rugged_adapter (1.0)
i18n (1.8.3)
io-console (default: 0.5.6)
ipaddr (default: 1.2.2)
irb (default: 1.2.3)
json (default: 2.3.0)
kramdown (2.1.0)
kramdown-parser-gfm (1.0.1)
libv8 (7.3.492.27.1 x86_64-linux)
logger (default: 1.4.2)
loofah (2.5.0)
matrix (default: 0.2.0)
mime-types (3.3.1)
mime-types-data (3.2020.0512)
mini_mime (1.0.2)
mini_portile2 (2.4.0)
mini_racer (0.2.14)
minitest (5.13.0)
multi_json (1.14.1)
mustache (0.99.8)
mustermann (1.1.1)
mutex_m (default: 0.1.0)
net-pop (default: 0.1.0)
net-smtp (default: 0.1.0)
net-telnet (0.2.0)
nokogiri (1.10.9)
observer (default: 0.1.0)
octicons (8.5.0)
open3 (default: 0.1.0)   
openssl (default: 2.1.2) 
ostruct (default: 0.2.0) 
power_assert (1.1.7)
prime (default: 0.1.1)   
pstore (default: 0.1.0)  
psych (default: 3.1.0)   
racc (default: 1.4.16)   
rack (2.2.2)
rack-protection (2.0.8.1)
rack-ssl (1.4.1)
rake (13.0.1)
rb-fsevent (0.10.4)
rb-inotify (0.10.1)
rdoc (default: 6.2.1)
readline (default: 0.0.2)
readline-ext (default: 0.1.0)
reline (default: 0.1.3)  
rexml (default: 3.2.3)   
rouge (3.20.0)
rss (0.2.9, default: 0.2.8)
ruby-enum (0.8.0)
ruby2_keywords (0.0.2)   
rugged (1.0.0, 0.99.0)   
sass (3.7.4)
sass-listen (4.0.0)
sdbm (default: 1.0.0)
sinatra (2.0.8.1)
sinatra-contrib (2.0.8.1)
singleton (default: 0.1.0)
sprockets (3.7.2)
sprockets-helpers (1.3.0)
stringio (default: 0.1.0)
strscan (default: 1.0.3) 
test-unit (3.3.4)
therubyrhino (2.1.2)
therubyrhino_jar (1.7.8) 
thin (1.7.2)
tilt (2.0.10)
timeout (default: 0.1.0) 
tracer (default: 0.1.0)  
twitter-text (1.14.7)
uglifier (3.2.0)
unf (0.1.4)
unf_ext (0.0.7.7)
uri (default: 0.10.0)
useragent (0.16.10)
webrick (default: 1.6.0) 
xmlrpc (0.3.0)
yaml (default: 0.1.0)
zlib (default: 1.1.0)
@acavalin acavalin changed the title error fetching images uploaded through the editor if the path contains spaces error fetching images uploaded through the editor when the path contains spaces Jun 25, 2020
@gpit2286
Copy link

I just ran into this - This appears to come from the program creating a folder with the url escaped string (%20) as opposed to the space character. This also needs to change the file path that is put into the editor text as it is also escaped. (%20 and not ' ')

I'm not familiar with the code base, but I would assume that simply decoding the URL before writing the file path would fix this as well as the code to add the img path to the editor.

heavywatal added a commit to heavywatal/gollum that referenced this issue Jul 12, 2020
'%20' in filenames are translated back to ' ' in both editor and file creation.
@dometto dometto closed this as completed in 627ee5b Aug 3, 2020
@dometto
Copy link
Member

dometto commented Aug 3, 2020

Should be resolved by @heavywatal in #1595 -- will do a bugfix release of gollum soon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants