From 075b6226437565d4d3d3071c4083bee9bca54e13 Mon Sep 17 00:00:00 2001 From: jmax-fearless <66315527+jmax-fearless@users.noreply.github.com> Date: Fri, 19 Mar 2021 12:08:26 -0400 Subject: [PATCH] SRCH-1772 validate RoutedQuery#url (#670) --- app/models/routed_query.rb | 2 +- spec/models/routed_query_spec.rb | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/routed_query.rb b/app/models/routed_query.rb index c3a440569b..2cdad89be9 100644 --- a/app/models/routed_query.rb +++ b/app/models/routed_query.rb @@ -11,7 +11,7 @@ class RoutedQuery < ApplicationRecord validates_uniqueness_of :description, scope: :affiliate_id validates :affiliate, presence: true - validates_format_of :url, with: URI.regexp + validates_url :url validate :keywords_cannot_be_blank diff --git a/spec/models/routed_query_spec.rb b/spec/models/routed_query_spec.rb index 824294cbae..43bd3dd540 100644 --- a/spec/models/routed_query_spec.rb +++ b/spec/models/routed_query_spec.rb @@ -32,6 +32,7 @@ it { is_expected.to validate_presence_of :affiliate } it { is_expected.to allow_value('http://www.foo.com').for(:url) } it { is_expected.not_to allow_value('www.foo.com').for(:url) } + it { is_expected.not_to allow_value('data:text/;&Tab.base64').for(:url) } it 'creates a new instance given valid attributes' do affiliate.routed_queries.create!(valid_attributes)