Skip to content

Instantly share code, notes, and snippets.

@vigetlabs
vigetlabs / statham_sanitizer.rb
Created November 23, 2009 15:06
HTML::StathamSanitizer
module HTML
class StathamSanitizer < WhiteListSanitizer
protected
def tokenize(text, options)
super.map do |token|
if token.is_a?(HTML::Tag) && options[:parent].include?(token.name)
token.to_s.gsub(/</, "&lt;")
else
@vigetlabs
vigetlabs / http_redirect_test.rb
Created February 24, 2009 14:28
Test Drive mod_rewrite With Test::Unit
require 'resource_path'
require 'redirect_check'
require 'test/unit'
class HTTPRedirectTest < Test::Unit::TestCase
def default_test; end # placeholder to stop Test::Unit from complaining
def self.domain=(domain)
RedirectCheck.domain = domain
class Object
def truthy?
!(self.nil? ||
self == false ||
self == 0 ||
self == '0' ||
self == '' ||
self == [] ||
self == { } )
end