parent
ccaff5c40e
commit
c226d8e85e
2 changed files with 11 additions and 2 deletions
|
@ -125,7 +125,10 @@ module BrowseTagsHelper
|
|||
nil
|
||||
end
|
||||
|
||||
def email_link(_key, value)
|
||||
def email_link(key, value)
|
||||
# Avoid converting conditional tags into emails, since EMAIL_REGEXP is quite permissive
|
||||
return nil unless %w[email contact:email].include? key
|
||||
|
||||
# Does the value look like an email? eg "someone@domain.tld"
|
||||
|
||||
# Uses Ruby built-in regexp to validate email.
|
||||
|
|
|
@ -50,7 +50,7 @@ class BrowseTagsHelperTest < ActionView::TestCase
|
|||
html = format_value("colour", "#f00")
|
||||
assert_dom_equal %(<span class="colour-preview-box" data-colour="#f00" title="Colour #f00 preview"></span>#f00), html
|
||||
|
||||
html = format_value("contact", "foo@example.com")
|
||||
html = format_value("email", "foo@example.com")
|
||||
assert_dom_equal "<a title=\"Email foo@example.com\" href=\"mailto:foo@example.com\">foo@example.com</a>", html
|
||||
|
||||
html = format_value("source", "https://example.com")
|
||||
|
@ -269,6 +269,12 @@ class BrowseTagsHelperTest < ActionView::TestCase
|
|||
# Strips whitespace at ends
|
||||
email = email_link("email", " test@email.com ")
|
||||
assert_equal "test@email.com", email
|
||||
|
||||
email = email_link("contact:email", "example@example.com")
|
||||
assert_equal "example@example.com", email
|
||||
|
||||
email = email_link("maxweight:conditional", "none@agricultural")
|
||||
assert_nil email
|
||||
end
|
||||
|
||||
def test_telephone_links
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue