regex escaping when using variables

This commit is contained in:
Christian Mehlmauer
2012-09-20 22:26:34 +02:00
parent 55996b4c90
commit 48b0e88c95
6 changed files with 11 additions and 9 deletions

View File

@@ -93,10 +93,10 @@ class WpTarget
# Only use the path because domain can be text or an ip
uri_path = @uri.path
if index_body[/#{uri_path}\/wp-content\/(?:themes|plugins)\//i]
if index_body[/#{Regexp.escape(uri_path)}\/wp-content\/(?:themes|plugins)\//i]
@wp_content_dir = "wp-content"
else
@wp_content_dir = index_body[/(?:href|src)\s*=\s*(?:"|').+#{uri_path}([^"']+)\/(?:themes|plugins)\/.*(?:"|')/i, 1]
@wp_content_dir = index_body[/(?:href|src)\s*=\s*(?:"|').+#{Regexp.escape(uri_path)}([^"']+)\/(?:themes|plugins)\/.*(?:"|')/i, 1]
end
end
@wp_content_dir