Fixed false positive theme detection

This commit is contained in:
Christian Mehlmauer
2014-07-16 18:25:35 +02:00
parent 102e30c29a
commit 6ebb9b6f66
6 changed files with 50 additions and 22 deletions

View File

@@ -15,9 +15,9 @@ class WpTheme < WpItem
include WpTheme::Output
include WpTheme::Childtheme
attr_writer :style_url
attr_accessor :additional_url
def allowed_options; super << :style_url end
def allowed_options; super << :additional_url end
def initialize(*args)
super(*args)
@@ -36,10 +36,7 @@ class WpTheme < WpItem
# @return [ String ] The url to the theme stylesheet
def style_url
unless @style_url
@style_url = uri.merge('style.css').to_s
end
@style_url
uri.merge('style.css').to_s
end
end

View File

@@ -30,13 +30,13 @@ class WpTheme < WpItem
response = Browser.get_and_follow_location(target_uri.to_s)
# https + domain is optional because of relative links
matches = %r{(?:https?://[^"']+)?/([^/]+)/themes/([^"']+)/style.css}i.match(response.body)
matches = /(?:https?:\/\/[^"']+)?\/([^\/]+)\/themes\/([^"'\/]+)[^"']*\/style.css/i.match(response.body)
if matches
return new(
target_uri,
{
name: matches[2],
style_url: matches[0],
additional_url: matches[0],
wp_content_dir: matches[1]
}
)

View File

@@ -7,6 +7,7 @@ class WpTheme
def additional_output(verbose = false)
theme_desc = verbose ? @theme_description : truncate(@theme_description, 100)
puts " | Style URL: #{style_url}"
puts " | Additional URL: #{additional_url}" if additional_url
puts " | Theme Name: #@theme_name" if @theme_name
puts " | Theme URI: #@theme_uri" if @theme_uri
puts " | Description: #{theme_desc}"