Commit 91fa82d1 authored by Douwe Maan's avatar Douwe Maan

Merge branch 'rs-help-path-traversal' into 'master'

Fix path traversal in HelpController

Closes #2543

See merge request !1922
parents 20491498 a42c548a
...@@ -10,7 +10,8 @@ class HelpController < ApplicationController ...@@ -10,7 +10,8 @@ class HelpController < ApplicationController
respond_to do |format| respond_to do |format|
format.any(:markdown, :md, :html) do format.any(:markdown, :md, :html) do
path = Rails.root.join('doc', @category, "#{@file}.md") # Note: We are purposefully NOT using `Rails.root.join`
path = File.join(Rails.root, 'doc', @category, "#{@file}.md")
if File.exist?(path) if File.exist?(path)
@markdown = File.read(path) @markdown = File.read(path)
...@@ -24,7 +25,8 @@ class HelpController < ApplicationController ...@@ -24,7 +25,8 @@ class HelpController < ApplicationController
# Allow access to images in the doc folder # Allow access to images in the doc folder
format.any(:png, :gif, :jpeg) do format.any(:png, :gif, :jpeg) do
path = Rails.root.join('doc', @category, "#{@file}.#{params[:format]}") # Note: We are purposefully NOT using `Rails.root.join`
path = File.join(Rails.root, 'doc', @category, "#{@file}.#{params[:format]}")
if File.exist?(path) if File.exist?(path)
send_file(path, disposition: 'inline') send_file(path, disposition: 'inline')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment