Revert "Remove bad mailto links"

This reverts commit 77f62a52a6.

refs LS-2622

Change-Id: Ie73c00fffbf1fc2f62448797ca0022feed8998bc
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/273715
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
QA-Review: Jeremy Stanley <jeremy@instructure.com>
Product-Review: Jeremy Stanley <jeremy@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
This commit is contained in:
Eric Saupe 2021-09-16 10:23:46 -07:00
parent 2a7f48ad61
commit 319f5b45e7
2 changed files with 0 additions and 22 deletions

View File

@ -212,15 +212,6 @@ module UserContent
asset_types = AssetTypes.reject { |k,v| !@allowed_types.include?(k) }
# Remove any bad mailto links
doc = Nokogiri::HTML5.fragment(html)
doc.css('a[href^="mailto:"]').each do |mailto|
email = mailto['href'][7..]
next if EmailAddressValidator.valid?(email)
html = html.gsub(mailto.to_html, mailto.text)
end
html.gsub(@toplevel_regex) do |url|
_absolute_part, prefix, type, obj_id, rest = [$1, $2, $3, $4, $5]
next url if !@contextless_types.include?(type) && prefix != @context_prefix && url != @context_prefix

View File

@ -303,18 +303,5 @@ describe CC::CCHelper do
HTML
}.not_to raise_error
end
it "should remove invalid mailto links" do
@exporter = CC::CCHelper::HtmlContentExporter.new(@course, @user, :for_course_copy => true)
html = %{
<a href="mailto:.">bad mailto</a>
<a href="mailto:good@test.test">good mailto</a>
}
translated = @exporter.html_content(html)
expect(translated).to eq %{
bad mailto
<a href="mailto:good@test.test">good mailto</a>
}
end
end
end