Sha256: 62f75bae8f64c8abdb1a11cbd32bbc3537cbb7b9ba9ac9d4585f60cd64e91e2a

Contents?: true

Size: 945 Bytes

Versions: 15

Compression:

Stored size: 945 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 :call_without_env_instance_var, :call
    alias_method :call, :call_with_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

15 entries across 15 versions & 1 rubygems

Version Path
locomotivecms-4.2.0.alpha2 config/initializers/deny_phantomjs_ttf.rb
locomotivecms-4.2.0.alpha1 config/initializers/deny_phantomjs_ttf.rb
locomotivecms-4.1.1 config/initializers/deny_phantomjs_ttf.rb
locomotivecms-4.1.0 config/initializers/deny_phantomjs_ttf.rb
locomotivecms-4.1.0.rc1 config/initializers/deny_phantomjs_ttf.rb
locomotivecms-4.0.3 config/initializers/deny_phantomjs_ttf.rb
locomotivecms-4.0.2 config/initializers/deny_phantomjs_ttf.rb
locomotivecms-4.0.1 config/initializers/deny_phantomjs_ttf.rb
locomotivecms-4.0.0 config/initializers/deny_phantomjs_ttf.rb
locomotivecms-4.0.0.rc0 config/initializers/deny_phantomjs_ttf.rb
locomotivecms-4.0.0.alpha3 config/initializers/deny_phantomjs_ttf.rb
locomotivecms-3.4.1 config/initializers/deny_phantomjs_ttf.rb
locomotivecms-4.0.0.alpha2 config/initializers/deny_phantomjs_ttf.rb
locomotivecms-4.0.0.alpha1 config/initializers/deny_phantomjs_ttf.rb
locomotivecms-3.4.0 config/initializers/deny_phantomjs_ttf.rb