From 61bc04ccaa064fb8bb6ee9d9db531d24ec86dc49 Mon Sep 17 00:00:00 2001 From: Wan Qi Chen Date: Thu, 9 Mar 2017 22:40:20 +0400 Subject: [PATCH 1/8] Fix issue when version is not formatted as expected Some plugins remove the version number for security --- lib/sniffles/sniffers/cms/wordpress.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/sniffles/sniffers/cms/wordpress.rb b/lib/sniffles/sniffers/cms/wordpress.rb index 64b5b93..44e4078 100644 --- a/lib/sniffles/sniffers/cms/wordpress.rb +++ b/lib/sniffles/sniffers/cms/wordpress.rb @@ -35,7 +35,11 @@ def parse_theme def parse_version version_meta_tag = text_at("//meta[@name='generator']/@content") - @output[:version] = (version_meta_tag ? extract_version(version_meta_tag)[1] : version_meta_tag) + @output[:version] = version_meta_tag + + if version = extract_version(version_meta_tag) + @output[:version] = version[1] + end end def parse_pingback From 6f87bc6765fb11fcc5938d3fd2c3ffa4f38de105 Mon Sep 17 00:00:00 2001 From: Wan Qi Chen Date: Sun, 12 Mar 2017 18:21:22 +0400 Subject: [PATCH 2/8] Fix error when version tag is missing Don't try to extract the version number when the version tag is missing --- lib/sniffles/sniffers/cms/wordpress.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sniffles/sniffers/cms/wordpress.rb b/lib/sniffles/sniffers/cms/wordpress.rb index 44e4078..5f5af35 100644 --- a/lib/sniffles/sniffers/cms/wordpress.rb +++ b/lib/sniffles/sniffers/cms/wordpress.rb @@ -37,7 +37,7 @@ def parse_version version_meta_tag = text_at("//meta[@name='generator']/@content") @output[:version] = version_meta_tag - if version = extract_version(version_meta_tag) + if @output[:version] && version = extract_version(version_meta_tag) @output[:version] = version[1] end end From 086b0589f23cd7c5a9f38428b1d134160bedf33e Mon Sep 17 00:00:00 2001 From: Wan Qi Chen Date: Fri, 20 Apr 2018 00:40:24 +0400 Subject: [PATCH 3/8] Fix text when multiple nodes matches the same pattern --- lib/sniffles/html.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sniffles/html.rb b/lib/sniffles/html.rb index 2ecb0f0..67e3a57 100644 --- a/lib/sniffles/html.rb +++ b/lib/sniffles/html.rb @@ -6,7 +6,7 @@ def parse(html) def text_at(pattern) if (nodes = @doc.search(pattern)).any? - nodes.text + nodes.map(&:value).uniq.first else false end From c715944c1bdacd498678fc6f1b755ceb932da440 Mon Sep 17 00:00:00 2001 From: Wan Qi Chen Date: Tue, 8 May 2018 11:40:58 +0400 Subject: [PATCH 4/8] Relax nokogiri version --- sniffles.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sniffles.gemspec b/sniffles.gemspec index e6c7e15..67925c9 100644 --- a/sniffles.gemspec +++ b/sniffles.gemspec @@ -14,7 +14,7 @@ Gem::Specification.new do |gem| gem.require_paths = ["lib"] gem.version = Sniffles::VERSION - gem.add_runtime_dependency("nokogiri", "~> 1.6.1") + gem.add_runtime_dependency("nokogiri", "~> 1.6") gem.add_development_dependency("rspec", "~> 2.9.0") gem.add_development_dependency("typhoeus", "~> 0.3.3") From d5a182e592d9d3d6560473fd245ce352609a0e13 Mon Sep 17 00:00:00 2001 From: Wan Qi Chen Date: Fri, 2 Nov 2018 10:41:10 +0400 Subject: [PATCH 5/8] Return links href attribute instead of nodes --- lib/sniffles/sniffers/cms/invision.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sniffles/sniffers/cms/invision.rb b/lib/sniffles/sniffers/cms/invision.rb index 2098797..a7a3d50 100644 --- a/lib/sniffles/sniffers/cms/invision.rb +++ b/lib/sniffles/sniffers/cms/invision.rb @@ -28,7 +28,7 @@ def parse_version end def copyright_link - text_at("//p[@id='copyright']/a") + text_at("//p[@id='copyright']/a/@href") end end end From 29633f833f9d63d02ce5935d145d534c4b02d441 Mon Sep 17 00:00:00 2001 From: Wan Qi Chen Date: Sun, 4 Nov 2018 13:55:19 +0400 Subject: [PATCH 6/8] Handle CSS files outside of theme folder --- lib/sniffles/sniffers/cms/wordpress.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sniffles/sniffers/cms/wordpress.rb b/lib/sniffles/sniffers/cms/wordpress.rb index 5f5af35..d51d9ff 100644 --- a/lib/sniffles/sniffers/cms/wordpress.rb +++ b/lib/sniffles/sniffers/cms/wordpress.rb @@ -30,7 +30,7 @@ def parse_feed def parse_theme theme_uri = text_at("//link[@rel='stylesheet' and contains(@href,'wp-content/themes/')][1]/@href") - @output[:theme] = (theme_uri ? clean_theme_uri(theme_uri)[1] : false) + @output[:theme] = theme_uri && clean_theme_uri(theme_uri)&.fetch(1) end def parse_version From d5e2876539ef01c1155222efaca7aeb8d84f1f43 Mon Sep 17 00:00:00 2001 From: Wan Qi Chen Date: Sun, 4 Nov 2018 15:14:21 +0400 Subject: [PATCH 7/8] Fix reading MatchData value --- lib/sniffles/sniffers/cms/wordpress.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sniffles/sniffers/cms/wordpress.rb b/lib/sniffles/sniffers/cms/wordpress.rb index d51d9ff..16aaa0d 100644 --- a/lib/sniffles/sniffers/cms/wordpress.rb +++ b/lib/sniffles/sniffers/cms/wordpress.rb @@ -30,7 +30,7 @@ def parse_feed def parse_theme theme_uri = text_at("//link[@rel='stylesheet' and contains(@href,'wp-content/themes/')][1]/@href") - @output[:theme] = theme_uri && clean_theme_uri(theme_uri)&.fetch(1) + @output[:theme] = theme_uri && clean_theme_uri(theme_uri)&.to_a[1] end def parse_version From bd797d01ead32951dce70b1ad11f4ae5742e3014 Mon Sep 17 00:00:00 2001 From: Wan Qi Chen Date: Sun, 4 Nov 2018 15:47:37 +0400 Subject: [PATCH 8/8] Fix error when array is nil --- lib/sniffles/sniffers/cms/wordpress.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sniffles/sniffers/cms/wordpress.rb b/lib/sniffles/sniffers/cms/wordpress.rb index 16aaa0d..d28f2a6 100644 --- a/lib/sniffles/sniffers/cms/wordpress.rb +++ b/lib/sniffles/sniffers/cms/wordpress.rb @@ -30,7 +30,7 @@ def parse_feed def parse_theme theme_uri = text_at("//link[@rel='stylesheet' and contains(@href,'wp-content/themes/')][1]/@href") - @output[:theme] = theme_uri && clean_theme_uri(theme_uri)&.to_a[1] + @output[:theme] = theme_uri && clean_theme_uri(theme_uri)&.to_a&.fetch(1, nil) end def parse_version