Unverified Commit 9240605a authored by Benjamin Neff's avatar Benjamin Neff Committed by Steffen van Bergerem
Browse files

Remove internet explorer version check

This was in all stack traces, which confused people ...

We currently only support IE11, so the version check was already old
again ...

When we break old browser versions, we don't check that for other
browsers. So older IE browser just break, like very other older browser
too.

closes #7557
parent 8f0c74f7
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@

## Refactor
* Remove title from profile photo upload button [#7551](https://github.com/diaspora/diaspora/pull/7551)
* Remove Internet Explorer workarounds [#7557](https://github.com/diaspora/diaspora/pull/7557)

## Bug fixes

+0 −2
Original line number Diff line number Diff line
@@ -5,7 +5,6 @@
# This file is used by Rack-based servers to start the application.

require ::File.expand_path("../config/environment",  __FILE__)
require ::File.expand_path("../lib/rack/internet_explorer_version", __FILE__)

# Kill unicorn workers really aggressively (at 300mb)
if defined?(Unicorn)
@@ -16,6 +15,5 @@ if defined?(Unicorn)
  use Unicorn::WorkerKiller::Oom, oom_min, oom_max
end
use Rack::Deflater
use Rack::InternetExplorerVersion, minimum: 9

run Diaspora::Application
+0 −41
Original line number Diff line number Diff line
#   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
+0 −47
Original line number Diff line number Diff line
#   Copyright (c) 2010-2011, Diaspora Inc.  This file is
#   licensed under the Affero General Public License version 3 or later.  See
#   the COPYRIGHT file.

describe Rack::InternetExplorerVersion do
  before :all do
    @app = Rack::Builder.parse_file(Rails.root.join("config.ru").to_s).first
  end

  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" do
      expect(subject.body).not_to match(/Diaspora doesn't support your version of Internet Explorer/)
    end
  end

  context "new IE" do
    let(:ua_string) { "MSIE 9" }

    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 "old IE" do
    let(:ua_string) { "MSIE 7" }

    it "should complain about the browser" do
      expect(subject.body).to match(/Diaspora doesn't support your version of Internet Explorer/)
    end

    it "should have the correct content-length header" do
      expect(subject.headers["Content-Length"]).to eq(subject.body.length.to_s)
    end
  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 "should complain about the browser" do
      expect(subject.body).to match(/Diaspora doesn't support your version of Internet Explorer/)
    end
  end
end