Navigation Link: fix regex to allow multiline SVG (#14481)
* Fix regex to check svg. Fixes #14334 * Add tests
This commit is contained in:
parent
f0093c5338
commit
c5c484408e
2 changed files with 7 additions and 1 deletions
|
|
@ -1,5 +1,5 @@
|
|||
class NavigationLink < ApplicationRecord
|
||||
SVG_REGEXP = /<svg .*>/i.freeze
|
||||
SVG_REGEXP = /<svg .*>/im.freeze
|
||||
|
||||
before_validation :allow_relative_url, if: :url?
|
||||
before_save :strip_local_hostname, if: :url?
|
||||
|
|
|
|||
|
|
@ -13,6 +13,12 @@ RSpec.describe NavigationLink, type: :model do
|
|||
it "validates the icon" do
|
||||
navigation_link.icon = "test.png"
|
||||
expect(navigation_link).not_to be_valid
|
||||
|
||||
navigation_link.icon = "<svg foo='bar'>"
|
||||
expect(navigation_link).to be_valid
|
||||
|
||||
navigation_link.icon = "<svg foo='bar'\nbaz='lol'\n\n more stuff...\n\n. >"
|
||||
expect(navigation_link).to be_valid
|
||||
end
|
||||
|
||||
context "when validating the URL" do
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue