parse_cf_email.rb: fix URI.unescape is obsolete

This commit is contained in:
Simon Legner 2020-11-24 23:02:25 +01:00
parent f5eb47fadf
commit fbfa9de39c
2 changed files with 18 additions and 1 deletions

View file

@ -12,7 +12,7 @@ module Docs
result += "%" + "0#{("0x#{slice.join}".hex ^ mask).to_s(16)}"[-2..-1]
end
node.replace(URI.decode(result))
node.replace(URI.decode_www_form_component(result))
end
doc

View file

@ -0,0 +1,17 @@
require 'test_helper'
require 'docs'
class ParseCfEmailFilterTest < MiniTest::Spec
include FilterTestHelper
self.filter_class = Docs::ParseCfEmailFilter
before do
context[:url] = 'http://example.com/dir/file'
end
it 'rewrites parses CloudFlare mail addresses' do
href = 'b3dddad0d6d2ddd7c0dadec3dfd6f3d6cbd2dec3dfd69dd0dcde'
@body = %(<a class="__cf_email__" data-cfemail="#{href}">Link</a>)
assert_equal 'niceandsimple@example.com', filter_output_string
end
end