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