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'
elsif %w(tex).include?(action_name)
@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'
else
@response.headers['Content-Type'] = 'text/html; charset=UTF-8'
end
end
@ -191,3 +193,15 @@ class ApplicationController < ActionController::Base
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
acupuncturealliance
acyclovir
Adipex
adultfriend
airline
allegra
ampicill
anafranil
@ -13,7 +10,6 @@ atenolol
attacke\.ch
autocorp
awardspace
blogspot\.com
bravehost\.com
butalbital
buy cheap
@ -44,7 +40,6 @@ hold-em
holdem
home\s*loan
hoodia
http://[A-Za-z0-9_\.]+\.cn
hydrocodone
I am really excited
I really like your site
@ -53,7 +48,6 @@ ketoconazole
lust cartoon
mijneigenweblog
Mortage
my homepage
myspace
naked
netfirms\.com
@ -70,7 +64,6 @@ porn
prohosting
protonix
rapidforum
replica
ringtone
rolex
serotonin
@ -78,7 +71,6 @@ singtaotor
slot\s*machin
soma
super site
texas
thepussies
tits
Tramadol
@ -93,5 +85,3 @@ Your site is great!
zoloft
\.iwarp\.
\.tripod\.com
\[link\=
\[url\=