Fixed false positive theme detection
This commit is contained in:
@@ -15,9 +15,9 @@ class WpTheme < WpItem
|
|||||||
include WpTheme::Output
|
include WpTheme::Output
|
||||||
include WpTheme::Childtheme
|
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)
|
def initialize(*args)
|
||||||
super(*args)
|
super(*args)
|
||||||
@@ -36,10 +36,7 @@ class WpTheme < WpItem
|
|||||||
|
|
||||||
# @return [ String ] The url to the theme stylesheet
|
# @return [ String ] The url to the theme stylesheet
|
||||||
def style_url
|
def style_url
|
||||||
unless @style_url
|
uri.merge('style.css').to_s
|
||||||
@style_url = uri.merge('style.css').to_s
|
|
||||||
end
|
|
||||||
@style_url
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -30,13 +30,13 @@ class WpTheme < WpItem
|
|||||||
response = Browser.get_and_follow_location(target_uri.to_s)
|
response = Browser.get_and_follow_location(target_uri.to_s)
|
||||||
|
|
||||||
# https + domain is optional because of relative links
|
# 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
|
if matches
|
||||||
return new(
|
return new(
|
||||||
target_uri,
|
target_uri,
|
||||||
{
|
{
|
||||||
name: matches[2],
|
name: matches[2],
|
||||||
style_url: matches[0],
|
additional_url: matches[0],
|
||||||
wp_content_dir: matches[1]
|
wp_content_dir: matches[1]
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ class WpTheme
|
|||||||
def additional_output(verbose = false)
|
def additional_output(verbose = false)
|
||||||
theme_desc = verbose ? @theme_description : truncate(@theme_description, 100)
|
theme_desc = verbose ? @theme_description : truncate(@theme_description, 100)
|
||||||
puts " | Style URL: #{style_url}"
|
puts " | Style URL: #{style_url}"
|
||||||
|
puts " | Additional URL: #{additional_url}" if additional_url
|
||||||
puts " | Theme Name: #@theme_name" if @theme_name
|
puts " | Theme Name: #@theme_name" if @theme_name
|
||||||
puts " | Theme URI: #@theme_uri" if @theme_uri
|
puts " | Theme URI: #@theme_uri" if @theme_uri
|
||||||
puts " | Description: #{theme_desc}"
|
puts " | Description: #{theme_desc}"
|
||||||
|
|||||||
@@ -52,6 +52,13 @@ describe 'WpTheme::Findable' do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'when other style.css is referenced' do
|
||||||
|
it 'returns the WpTheme' do
|
||||||
|
@file = 'yootheme.html'
|
||||||
|
@expected = WpTheme.new(uri, name: 'yoo_solar_wp')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '::find_from_wooframework' do
|
describe '::find_from_wooframework' do
|
||||||
|
|||||||
@@ -29,24 +29,11 @@ describe WpTheme do
|
|||||||
let(:theme_path) { 'wp-content/themes/theme-name/' }
|
let(:theme_path) { 'wp-content/themes/theme-name/' }
|
||||||
|
|
||||||
describe '#allowed_options' do
|
describe '#allowed_options' do
|
||||||
its(:allowed_options) { is_expected.to include :style_url }
|
its(:allowed_options) { is_expected.to include :additional_url }
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#forge_uri' do
|
describe '#forge_uri' do
|
||||||
its(:uri) { is_expected.to eq uri.merge(theme_path) }
|
its(:uri) { is_expected.to eq uri.merge(theme_path) }
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#style_url' do
|
|
||||||
its(:style_url) { is_expected.to eq uri.merge(theme_path + '/style.css').to_s }
|
|
||||||
|
|
||||||
context 'when its already set' do
|
|
||||||
it 'returns it instead of the default one' do
|
|
||||||
url = uri.merge(theme_path + '/custom.css').to_s
|
|
||||||
wp_theme.style_url = url
|
|
||||||
|
|
||||||
expect(wp_theme.style_url).to eq url
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
|
||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html lang="de-DE" dir="ltr">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>XXXXX </title>
|
||||||
|
<link rel="EditURI" type="application/rsd+xml" title="RSD" href="http://domain.com/xmlrpc.php?rsd" />
|
||||||
|
<link rel="wlwmanifest" type="application/wlwmanifest+xml" href="http://domain.com/wp-includes/wlwmanifest.xml" />
|
||||||
|
<meta name="generator" content="WordPress 3.9.1" />
|
||||||
|
<link rel="stylesheet" href="/wp-content/themes/yoo_solar_wp/css/base.css" />
|
||||||
|
<link rel="stylesheet" href="/wp-content/themes/yoo_solar_wp/css/layout.css" />
|
||||||
|
<link rel="stylesheet" href="/wp-content/themes/yoo_solar_wp/css/menus.css" />
|
||||||
|
<link rel="stylesheet" href="/wp-content/themes/yoo_solar_wp/css/modules.css" />
|
||||||
|
<link rel="stylesheet" href="/wp-content/themes/yoo_solar_wp/css/tools.css" />
|
||||||
|
<link rel="stylesheet" href="/wp-content/themes/yoo_solar_wp/css/system.css" />
|
||||||
|
<link rel="stylesheet" href="/wp-content/themes/yoo_solar_wp/css/extensions.css" />
|
||||||
|
<link rel="stylesheet" href="/wp-content/themes/yoo_solar_wp/css/custom.css" />
|
||||||
|
<link rel="stylesheet" href="/wp-content/themes/yoo_solar_wp/css/animation.css" />
|
||||||
|
<link rel="stylesheet" href="/wp-content/themes/yoo_solar_wp/css/texture/noise.css" />
|
||||||
|
<link rel="stylesheet" href="/wp-content/themes/yoo_solar_wp/css/color/green.css" />
|
||||||
|
<link rel="stylesheet" href="/wp-content/themes/yoo_solar_wp/css/font1/droidsans.css" />
|
||||||
|
<link rel="stylesheet" href="/wp-content/themes/yoo_solar_wp/css/font2/droidsans.css" />
|
||||||
|
<link rel="stylesheet" href="/wp-content/themes/yoo_solar_wp/css/font3/droidsans.css" />
|
||||||
|
<link rel="stylesheet" href="/wp-content/themes/yoo_solar_wp/styles/wood/css/style.css" />
|
||||||
|
<link rel="stylesheet" href="/wp-content/themes/yoo_solar_wp/css/responsive.css" />
|
||||||
|
<link rel="stylesheet" href="/wp-content/themes/yoo_solar_wp/css/print.css" />
|
||||||
|
<link rel="stylesheet" href="/wp-content/themes/yoo_solar_wp/fonts/droidsans.css" />
|
||||||
|
<script src="/wp-content/themes/yoo_solar_wp/warp/js/warp.js"></script>
|
||||||
|
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body></body>
|
||||||
|
</html>
|
||||||
Reference in New Issue
Block a user