Browse Source

Fixes #4693 - URLs with protocol tel and a telephone number are not working.

Co-authored-by: Rolf Schmidt <rolf.schmidt@zammad.com>
Florian Liebe 1 year ago
parent
commit
de5abd2819

+ 1 - 0
lib/html_sanitizer/scrubber/link.rb

@@ -54,6 +54,7 @@ class HtmlSanitizer
         return if !external
         return if href_without_spaces.blank?
         return if href_without_spaces.downcase.start_with?('mailto:')
+        return if href_without_spaces.downcase.start_with?('tel:')
         return if href_without_spaces.downcase.start_with?('//')
         return if href_without_spaces.downcase.match? %r{^.{1,6}://.+?}
 

+ 7 - 0
spec/lib/html_sanitizer/scrubber/link_spec.rb

@@ -59,5 +59,12 @@ RSpec.describe HtmlSanitizer::Scrubber::Link do
 
       it { is_expected.to eq target }
     end
+
+    context 'when external URL with tel protocol' do
+      let(:input)  { '<a href="tel:+4930555716000">my telephone number</a>' }
+      let(:target) { '<a href="tel:+4930555716000">my telephone number</a>' }
+
+      it { is_expected.to eq target }
+    end
   end
 end