diff --git a/lib/common/models/wp_version/findable.rb b/lib/common/models/wp_version/findable.rb
index cd0a8dac..a771ff22 100644
--- a/lib/common/models/wp_version/findable.rb
+++ b/lib/common/models/wp_version/findable.rb
@@ -212,7 +212,12 @@ class WpVersion < WpItem
next if attr_value.nil? || attr_value.empty?
- uri = Addressable::URI.parse(attr_value)
+ begin
+ uri = Addressable::URI.parse(attr_value)
+ rescue Addressable::URI::InvalidURIError
+ next
+ end
+
next unless uri.query && uri.query.match(pattern)
version = Regexp.last_match[1].to_s
diff --git a/spec/lib/common/models/wp_version/findable_spec.rb b/spec/lib/common/models/wp_version/findable_spec.rb
index 2eafcc8f..f647a7dc 100644
--- a/spec/lib/common/models/wp_version/findable_spec.rb
+++ b/spec/lib/common/models/wp_version/findable_spec.rb
@@ -159,6 +159,22 @@ describe 'WpVersion::Findable' do
end
end
+ describe '::find_from_stylesheets_numbers' do
+ after do
+ fixture = fixtures_dir + 'stylesheet_numbers' + @fixture
+ stub_request_to_fixture(url: uri, fixture: fixture)
+
+ expect(WpVersion.send(:find_from_stylesheets_numbers, uri)).to eq @expected
+ end
+
+ context 'invalid url' do
+ it 'returns nil' do
+ @fixture = '/invalid_url.html'
+ @expected = nil
+ end
+ end
+ end
+
describe '::find' do
# Stub all WpVersion::find_from_* to return nil
def stub_all_to_nil
diff --git a/spec/samples/common/models/wp_version/findable/stylesheet_numbers/invalid_url.html b/spec/samples/common/models/wp_version/findable/stylesheet_numbers/invalid_url.html
new file mode 100644
index 00000000..04ccf538
--- /dev/null
+++ b/spec/samples/common/models/wp_version/findable/stylesheet_numbers/invalid_url.html
@@ -0,0 +1,8 @@
+
+