From 0190e08763f0779d17433e95de9c7ad589805b71 Mon Sep 17 00:00:00 2001 From: Victor Bogado Date: Sun, 1 Jan 2017 18:58:31 -0800 Subject: [PATCH] Fix page list for files that have regexp special chars. The page list collection logic was using the filename without any scaping to create a regexp. This not only breaks for some names it might even be a security problem by introducing bad regular expression as filenames. --- lib/gollum/views/pages.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/gollum/views/pages.rb b/lib/gollum/views/pages.rb index ff11fcf7..cf9f8b4e 100644 --- a/lib/gollum/views/pages.rb +++ b/lib/gollum/views/pages.rb @@ -36,7 +36,8 @@ module Precious # 1012: Folders and Pages need to be separated @results.each do |page| - page_path = page.path.sub(/^#{@path}\//, '') + page_path = page.path + page_path = page_path.sub(/^#{Regexp.escape(@path)}\//, '') unless @path.nil? if page_path.include?('/') folder = page_path.split('/').first