Class: Rack::AddressMunging::Strategy::Rot13JS

Inherits:
Object
  • Object
show all
Includes:
Detection
Defined in:
lib/rack/address_munging/strategy/rot13js.rb

Overview

The :Rot13JS munging strategy

Will replace email addresses and full mailto links with a <script> tag that will print it back into the page, based on a ROT13 version.

The ROT13 implementation used here is a bit different as the original one will not replace @. This fix it, applying a second replacement to switch @ with (at) in the munged string.

This strategy does not handle email addresses containing UTF-8 entities.

Constant Summary

Constants included from Detection

Detection::REGEXP_EMAIL, Detection::REGEXP_LINK, Detection::REGEXP_MAILTO

Instance Method Summary collapse

Methods included from Detection

#email?

Instance Method Details

#apply(munged, original) ⇒ Object



19
20
21
22
23
24
25
26
# File 'lib/rack/address_munging/strategy/rot13js.rb', line 19

def apply(munged, original)
  original.each do |part|
    part = part.dup if part.frozen?
    part.gsub!(REGEXP_LINK)   { |m| maybe_encode(m) }
    part.gsub!(REGEXP_EMAIL)  { |m| maybe_encode(m) }
    munged.write part
  end
end