Do content-negotiation to decide whether to send application/xhtml+xml or text/html.

Fixed the bozotic spam filter. Can you believe one can't use the word "texas" in Instiki?
This commit is contained in:
Jacques Distler 2007-01-23 03:25:24 -06:00
parent ceb0931bb3
commit 29b4c4b837
2 changed files with 15 additions and 11 deletions

View file

@ -148,8 +148,10 @@ class ApplicationController < ActionController::Base
@response.headers['Content-Type'] = 'text/xml; charset=UTF-8' @response.headers['Content-Type'] = 'text/xml; charset=UTF-8'
elsif %w(tex).include?(action_name) elsif %w(tex).include?(action_name)
@response.headers['Content-Type'] = 'text/plain; charset=UTF-8' @response.headers['Content-Type'] = 'text/plain; charset=UTF-8'
else elsif Mime::Type.parse(@request.env["HTTP_ACCEPT"]).include?(Mime::XHTML)
@response.headers['Content-Type'] = 'application/xhtml+xml; charset=UTF-8' @response.headers['Content-Type'] = 'application/xhtml+xml; charset=UTF-8'
else
@response.headers['Content-Type'] = 'text/html; charset=UTF-8'
end end
end end
@ -191,3 +193,15 @@ class ApplicationController < ActionController::Base
end end
end end
module Mime
# Fix HTML
#HTML = Type.new "text/html", :html, %w( application/xhtml+xml )
HTML = Type.new "text/html", :html
# Add XHTML
XHTML = Type.new "application/xhtml+xml", :xhtml
# Fix xhtml lookup
LOOKUP["application/xhtml+xml"] = XHTML
end

View file

@ -1,11 +1,8 @@
.*\[\/link\]
.*\[\/url\]
51wisdom 51wisdom
acupuncturealliance acupuncturealliance
acyclovir acyclovir
Adipex Adipex
adultfriend adultfriend
airline
allegra allegra
ampicill ampicill
anafranil anafranil
@ -13,7 +10,6 @@ atenolol
attacke\.ch attacke\.ch
autocorp autocorp
awardspace awardspace
blogspot\.com
bravehost\.com bravehost\.com
butalbital butalbital
buy cheap buy cheap
@ -44,7 +40,6 @@ hold-em
holdem holdem
home\s*loan home\s*loan
hoodia hoodia
http://[A-Za-z0-9_\.]+\.cn
hydrocodone hydrocodone
I am really excited I am really excited
I really like your site I really like your site
@ -53,7 +48,6 @@ ketoconazole
lust cartoon lust cartoon
mijneigenweblog mijneigenweblog
Mortage Mortage
my homepage
myspace myspace
naked naked
netfirms\.com netfirms\.com
@ -70,7 +64,6 @@ porn
prohosting prohosting
protonix protonix
rapidforum rapidforum
replica
ringtone ringtone
rolex rolex
serotonin serotonin
@ -78,7 +71,6 @@ singtaotor
slot\s*machin slot\s*machin
soma soma
super site super site
texas
thepussies thepussies
tits tits
Tramadol Tramadol
@ -93,5 +85,3 @@ Your site is great!
zoloft zoloft
\.iwarp\. \.iwarp\.
\.tripod\.com \.tripod\.com
\[link\=
\[url\=