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.
This commit is contained in:
Victor Bogado
2017-01-01 18:58:31 -08:00
parent d3cc5a69c4
commit 0190e08763
+2 -1
View File
@@ -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