Sha256: e753c9040253060f108da726897ef1c5b19a6ea83b1674a85ee16765a6aa2151

Contents?: true

Size: 884 Bytes

Versions: 59

Compression:

Stored size: 884 Bytes

Contents

# Monkey patch under test environment that prevents PhantomJS on OSX
# from crashing when dealing with TTF webfonts.
# Note: depending on your setup, it's likely that the RUBY_PLATFORM
# is not actually relevant for server - it's the UA that crashes.
#
# See:
#   https://github.com/jonleighton/poltergeist/issues/44
#   https://github.com/littlebtc/font-awesome-sass-rails/issues/11
#
if Rails.env.test? # && RUBY_PLATFORM =~ /darwin/
  module Sprockets::Server

    def call_with_env_instance_var(env)
      @env = env
      call_without_env_instance_var(env)
    end
    alias_method_chain :call, :env_instance_var

    def forbidden_request?(path)
      if @env['HTTP_USER_AGENT'] =~ /Intel Mac OS X.*PhantomJS/ && path =~ /ttf$/
        # STDERR.puts "Denying #{path} to #{@env['HTTP_USER_AGENT']}"
        true
      else
        path.include?("..")
      end
    end

  end
end

Version data entries

59 entries across 59 versions & 3 rubygems

Version Path
locomotivecms-3.3.0 config/initializers/deny_phantomjs_ttf.rb
locomotivecms-3.3.0.rc3 config/initializers/deny_phantomjs_ttf.rb
locomotivecms-3.3.0.rc2 config/initializers/deny_phantomjs_ttf.rb
locomotivecms-3.1.2 config/initializers/deny_phantomjs_ttf.rb
locomotivecms-3.2.1 config/initializers/deny_phantomjs_ttf.rb
locomotivecms-3.3.0.rc1 config/initializers/deny_phantomjs_ttf.rb
locomotivecms-3.2.0 config/initializers/deny_phantomjs_ttf.rb
locomotivecms-3.2.0.rc2 config/initializers/deny_phantomjs_ttf.rb
locomotivecms-3.2.0.rc1 config/initializers/deny_phantomjs_ttf.rb
locomotivecms-3.1.1 config/initializers/deny_phantomjs_ttf.rb
locomotivecms-3.1.0 config/initializers/deny_phantomjs_ttf.rb
locomotivecms-3.1.0.rc3 config/initializers/deny_phantomjs_ttf.rb
locomotivecms-3.1.0.rc2 config/initializers/deny_phantomjs_ttf.rb
locomotivecms-3.1.0.rc1 config/initializers/deny_phantomjs_ttf.rb
locomotivecms-3.0.1 config/initializers/deny_phantomjs_ttf.rb
locomotivecms-3.0.0 config/initializers/deny_phantomjs_ttf.rb
locomotivecms-3.0.0.rc7 config/initializers/deny_phantomjs_ttf.rb
locomotivecms-3.0.0.rc6 config/initializers/deny_phantomjs_ttf.rb
locomotivecms-3.0.0.rc5 config/initializers/deny_phantomjs_ttf.rb
locomotivecms-3.0.0.rc4 config/initializers/deny_phantomjs_ttf.rb