mirror of
https://github.com/middleman/middleman.git
synced 2022-11-09 12:20:27 -05:00
Escape filenames in regexes. Fixes #942.
This commit is contained in:
parent
a3e030e846
commit
f92ae94728
3 changed files with 3 additions and 3 deletions
|
@ -196,7 +196,7 @@ module Middleman::CoreExtensions
|
||||||
end
|
end
|
||||||
|
|
||||||
def normalize_path(path)
|
def normalize_path(path)
|
||||||
path.sub(%r{^#{app.source_dir}\/}, "")
|
path.sub(%r{^#{Regexp.escape(app.source_dir)}\/}, "")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -191,7 +191,7 @@ module Middleman
|
||||||
engine = File.extname(resource.source_file)[1..-1].to_sym
|
engine = File.extname(resource.source_file)[1..-1].to_sym
|
||||||
|
|
||||||
# Look for partials relative to the current path
|
# Look for partials relative to the current path
|
||||||
relative_dir = File.join(current_dir.sub(%r{^#{self.source_dir}/?}, ""), data)
|
relative_dir = File.join(current_dir.sub(%r{^#{Regexp.escape(self.source_dir)}/?}, ""), data)
|
||||||
|
|
||||||
# Try to use the current engine first
|
# Try to use the current engine first
|
||||||
found_partial, found_engine = resolve_template(relative_dir, :preferred_engine => engine, :try_without_underscore => true)
|
found_partial, found_engine = resolve_template(relative_dir, :preferred_engine => engine, :try_without_underscore => true)
|
||||||
|
|
|
@ -124,7 +124,7 @@ class Middleman::CoreExtensions::DefaultHelpers < ::Middleman::Extension
|
||||||
# If the basename of the request as no extension, assume we are serving a
|
# If the basename of the request as no extension, assume we are serving a
|
||||||
# directory and join index_file to the path.
|
# directory and join index_file to the path.
|
||||||
path = File.join(asset_dir, current_path)
|
path = File.join(asset_dir, current_path)
|
||||||
path = path.sub(/#{File.extname(path)}$/, ".#{asset_ext}")
|
path = path.sub(/#{Regexp.escape(File.extname(path))}$/, ".#{asset_ext}")
|
||||||
|
|
||||||
yield path if sitemap.find_resource_by_path(path)
|
yield path if sitemap.find_resource_by_path(path)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue