From 03ab3963536600be7e5020c813080678aa245ece Mon Sep 17 00:00:00 2001 From: erwanlr Date: Thu, 8 Jan 2015 23:26:36 +0100 Subject: [PATCH] Ensures that the version detected by stylesheets is present more than once. Ref #478 --- lib/common/models/wp_version/findable.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/common/models/wp_version/findable.rb b/lib/common/models/wp_version/findable.rb index ceb6a751..0bdf1c0c 100755 --- a/lib/common/models/wp_version/findable.rb +++ b/lib/common/models/wp_version/findable.rb @@ -117,7 +117,7 @@ class WpVersion < WpItem def find_from_stylesheets_numbers(target_uri) wp_versions = WpVersion.all found = {} - pattern = /ver=([0-9\.]+)/i + pattern = /\bver=([0-9\.]+)/i Nokogiri::HTML(Browser.get(target_uri.to_s).body).css('link,script').each do |tag| %w(href src).each do |attribute| @@ -138,7 +138,8 @@ class WpVersion < WpItem found.delete_if { |v, _| !wp_versions.include?(v) } best_guess = found.sort_by(&:last).last - best_guess ? best_guess[0] : nil + # best_guess[0]: version number, [1] numbers of occurences + best_guess && best_guess[1] > 1 ? best_guess[0] : nil end # Uses data/wp_versions.xml to try to identify a