Commit d97448e5 authored by Benjamin Neff's avatar Benjamin Neff Committed by Jonne Haß

remove ChromeFrame

Google Chrome Frame was a plugin for Internet Explorer, but is no longer
supported. And it was included with http and not https which triggered a
warning on most pods.

Also set the minimum version to 9 to support #6557

closes #6751
parent 6ea8cd54
......@@ -11,6 +11,7 @@
## Features
* Added the footer to conversation pages [#6710](https://github.com/diaspora/diaspora/pull/6710)
* Drop ChromeFrame and display an error page on old IE versions instead [#6751](https://github.com/diaspora/diaspora/pull/6751)
# 0.5.7.1
......
# Copyright (c) 2010-2011, Diaspora Inc. This file is
# Copyright (c) 2010-2011, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
# This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment', __FILE__)
require ::File.expand_path('../lib/unicorn_killer', __FILE__)
require ::File.expand_path('../lib/rack/chrome_frame', __FILE__)
require ::File.expand_path("../config/environment", __FILE__)
require ::File.expand_path("../lib/unicorn_killer", __FILE__)
require ::File.expand_path("../lib/rack/internet_explorer_version", __FILE__)
# Kill unicorn workers really agressively (at 300mb)
# Kill unicorn workers really aggressively (at 300mb)
if defined?(Unicorn)
use UnicornKiller::Oom, 300 * 1024
end
use Rack::Deflater
use Rack::ChromeFrame, :minimum => 8
use Rack::InternetExplorerVersion, minimum: 9
use Rack::Protection::FrameOptions
run Diaspora::Application
# Copyright (c) 2010-2011, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
module Rack
class ChromeFrame
def initialize(app, options={})
@app = app
@options = options
end
def call(env)
if env['HTTP_USER_AGENT'] =~ /MSIE/
if env['HTTP_USER_AGENT'] =~ /chromeframe/
status, headers, response = @app.call(env)
new_body = insert_tag(build_response_body(response))
new_headers = recalculate_body_length(headers, new_body)
return [status, new_headers, [new_body]]
elsif @options[:minimum].nil? or ie_version(env['HTTP_USER_AGENT']) < @options[:minimum]
html = <<-HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
<title>Diaspora doesn't support your version of Internet Explorer. Try Chrome, Firefox, or Opera!</title>
</head>
<body>
<div id="cf-placeholder"></div>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/chrome-frame/1/CFInstall.min.js"></script>
<script>CFInstall.check({ node: "cf-placeholder" #{', destination: "' + @options[:destination] + '" ' if @options[:destination]}});</script>
</body>
</html>
HTML
return [200, {'Content-Type' => 'text/html', 'Content-Length' => html.size.to_s}, Rack::Response.new([html])]
end
end
@app.call(env)
end
def build_response_body(response)
response_body = ""
response.each { |part| response_body += part }
# see: http://johnbintz.github.com/blog/2012/03/05/closing-given-body-in-rack-middleware/
response.close if response.respond_to?(:close)
response_body
end
def recalculate_body_length(headers, body)
new_headers = headers
new_headers["Content-Length"] = body.length.to_s
new_headers
end
def insert_tag(body)
head = <<-HEAD
<meta http-equiv="X-UA-Compatible" content="chrome=1">
HEAD
body.gsub!(/<head(.*)>/, "<head\\1>\n" + head )
body
end
def ie_version(ua_string)
ua_string.match(/MSIE ?(\S+)/)[1].to_f
end
end
end
# Copyright (c) 2010-2011, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
module Rack
class InternetExplorerVersion
def initialize(app, options={})
@app = app
@options = options
end
def call(env)
if env["HTTP_USER_AGENT"] =~ /MSIE/ && ie_version(env["HTTP_USER_AGENT"]) < @options[:minimum]
html = <<-HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
<title>Diaspora doesn't support your version of Internet Explorer. Try Firefox, Chrome or Opera!</title>
</head>
<body>
<h1>Diaspora doesn't support your version of Internet Explorer.</h1>
You can use one of these browsers (and many more):
<ul>
<li><a href="https://www.mozilla.org/firefox/">Firefox</a></li>
<li><a href="https://www.google.com/chrome/">Chrome</a></li>
<li><a href="https://www.opera.com/">Opera</a></li>
</ul>
</body>
</html>
HTML
return [200, {"Content-Type" => "text/html", "Content-Length" => html.size.to_s}, Rack::Response.new([html])]
end
@app.call(env)
end
def ie_version(ua_string)
ua_string.match(/MSIE ?(\S+)/)[1].to_f
end
end
end
# Copyright (c) 2010-2011, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
require 'spec_helper'
describe Rack::ChromeFrame do
require "spec_helper"
describe Rack::InternetExplorerVersion do
before :all do
@app = Rack::Builder.parse_file(Rails.root.join('config.ru').to_s).first
end
before :each do
@response = get_response_for_user_agent(@app, ua_string);
@app = Rack::Builder.parse_file(Rails.root.join("config.ru").to_s).first
end
subject { @response }
subject { get_response_for_user_agent(@app, ua_string) }
context "non-IE browser" do
let(:ua_string) { "another browser chromeframe" }
it "shouldn't complain about the browser and shouldn't have chrome frame" do
expect(subject.body).not_to match(/chrome=1/)
it "shouldn't complain about the browser" do
expect(subject.body).not_to match(/Diaspora doesn't support your version of Internet Explorer/)
end
end
context "IE8 without chromeframe" do
let(:ua_string) { "MSIE 8" }
context "new IE" do
let(:ua_string) { "MSIE 9" }
it "shouldn't complain about the browser and shouldn't have chrome frame" do
expect(subject.body).not_to match(/chrome=1/)
it "shouldn't complain about the browser" do
expect(subject.body).not_to match(/Diaspora doesn't support your version of Internet Explorer/)
end
end
context "IE7 without chromeframe" do
context "old IE" do
let(:ua_string) { "MSIE 7" }
it "should complain about the browser" do
expect(subject.body).not_to match(/chrome=1/)
expect(subject.body).to match(/Diaspora doesn't support your version of Internet Explorer/)
end
specify {expect(@response.headers["Content-Length"]).to eq(@response.body.length.to_s)}
end
context "any IE with chromeframe" do
let(:ua_string) { "MSIE number chromeframe" }
it "shouldn't complain about the browser and should have chrome frame" do
expect(subject.body).to match(/chrome=1/)
expect(subject.body).not_to match(/Diaspora doesn't support your version of Internet Explorer/)
it "should have the correct content-length header" do
expect(subject.headers["Content-Length"]).to eq(subject.body.length.to_s)
end
specify {expect(@response.headers["Content-Length"]).to eq(@response.body.length.to_s)}
end
context "Specific case with no space after MSIE" do
let(:ua_string) { "Mozilla/4.0 (compatible; MSIE8.0; Windows NT 6.0) .NET CLR 2.0.50727" }
it "shouldn't complain about the browser" do
expect(subject.body).not_to match(/Diaspora doesn't support your version of Internet Explorer/)
it "should complain about the browser" do
expect(subject.body).to match(/Diaspora doesn't support your version of Internet Explorer/)
end
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment