Low commit activity in last 3 years
No release in over a year
A Rack middleware for automatic e-mail addresses munging.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.1
~> 13.0
~> 3.10.0

Runtime

> 2.5.0
>= 2.1.4
 Project Readme

Rack::AddressMunging

Unit tests Gem Version

Rack::AddressMunging is a Rack middleware for automatic e-mail addresses munging.

Once added to your middleware stack, Rack::AddressMunging will parse the body of any HTML response and mung it to obfuscate email addresses, in hope to prevent spambots to collect them too easily.

Installation

Rack::AddressMunging is distributed as a gem and available on rubygems.org so you can add it to your Gemfile or install it manually with:

gem install rack-address_munging

Usage

To use the middleware with it's default configuration, just drop it in your middleware stack:

# In config.ru or wherever your stack is defined
require 'rack/address_munging'

use Rack::AddressMunging

If you want to use another munging strategy, precise it as an argument:

# In a Rails initializer
require 'rack/address_munging'

module YourRailsAppName
  class Application
    config.middleware.use Rack::AddressMunging, strategy: :hex
  end
end

Supported Strategies

:Hex

Replace email addresses and mailto href attributes values with an hexadecimal entities alternative.

Input:  email@example.com
Output: email@example.com

:Hex is the default strategy.

:Rot13JS

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

Input:  email@example.com
Output: <script type="text/javascript">document.write("rznvy(at)rknzcyr.pbz".replace(/(at)/, '@').replace(/[a-z]/gi,function(c){return String.fromCharCode((c<="Z"?90:122)>=(c=c.charCodeAt(0)+13)?c:c-26);});))</script>

For more informations about the exact behavior of each strategy, please refer to the strategies specs data.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/notus-sh/rack-address_munging.