/rack-delinkify

comment-spam protection: serve a webpage without links, with optional domain whitelist parameter

Primary LanguageRubyOtherNOASSERTION

Rack::Delinkify

Description

To prevent or clean up unwanted links from your Rack or Rack-dependent app, use Rack::Delinkify.

In default usage, links are converted from HTML <a> elements to <span>s. The links’ text components are rendered. You can optionally set Rack::Delinkify to obliterate the entire HTML element, rather than render the text component.

Rack::Delinkify also provides the option to specify a whitelist of domain names. Links to those domains (and subdomains thereof) are preserved in the HTML response.

The options can be used together, in which case the link elements that are not preserved by the whitelist are obliterated. Rack::Delinkify could be used in this way to defang an attack of comment-link-spamming.

Usage

Use as you would any other Rack ware in your stack.

Disable all links, render links’ text components

use Rack::Delinkify

Eliminate all <a> elements entirely, including text component

use Rack::Delinkify, :obliterate => true

Preserve links to domain names qualified to any level

use Rack::Delinkify, :except => [ "example.com", "edu", "ajax.googleapis.com" ]

Contributing to rack-delinkify

  • Check out the latest master to make sure the feature hasn’t been implemented or the bug hasn’t been fixed yet

  • Check out the issue tracker to make sure someone already hasn’t requested it and/or contributed it

  • Fork the project

  • Start a feature/bugfix branch

  • Commit and push until you are happy with your contribution

  • Make sure to add tests for it. This is important so I don’t break it in a future version unintentionally.

  • Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.

License

Rack::Delinkify is released under the MIT License; details are in the LICENSE file.