lib/roadie/filesystem_provider.rb in roadie-3.0.0.pre1 vs lib/roadie/filesystem_provider.rb in roadie-3.0.0

- old
+ new

@@ -13,21 +13,32 @@ def initialize(path = Dir.pwd) @path = path end - # @raise InsecurePathError # @return [Stylesheet, nil] def find_stylesheet(name) file_path = build_file_path(name) if File.exist? file_path Stylesheet.new file_path, File.read(file_path) end end + # @raise InsecurePathError + # @return [Stylesheet] + def find_stylesheet!(name) + file_path = build_file_path(name) + if File.exist? file_path + Stylesheet.new file_path, File.read(file_path) + else + clean_name = File.basename file_path + raise CssNotFound.new(clean_name, %{#{file_path} does not exist. (Original name was "#{name}")}) + end + end + private def build_file_path(name) raise InsecurePathError, name if name.include?("..") - File.join(@path, name) + File.join(@path, name[/^([^?]+)/]) end end end