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

Fix for #3068 (Windows Path Sanitation) #3071

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 8 additions & 5 deletions lib/jekyll.rb
Expand Up @@ -141,13 +141,16 @@ def sites
#
# Returns the sanitized path.
def sanitized_path(base_directory, questionable_path)
clean_path = File.expand_path(questionable_path, "/")
clean_path.gsub!(/\A\w\:\//, '/')
unless clean_path.start_with?(base_directory)
File.join(base_directory, clean_path)
relative_path = if questionable_path.start_with? base_directory
# Convert questionable_path to be relative to the base_directory
questionable_path.sub(base_directory, '')
else
clean_path
questionable_path
end

clean_path = File.expand_path(relative_path, '/')
clean_path.gsub!(/\A\w\:\//, '/')
File.join(base_directory, clean_path)
end

end
Expand Down