From cb5dcb336fd1d975bf546685f67020090a2d91e7 Mon Sep 17 00:00:00 2001 From: kares Date: Tue, 30 Dec 2014 08:51:25 +0100 Subject: [PATCH 01/27] update pom to generate sources/javadoc and sign + prepare for release 1.1.17 --- History.md | 10 ++++++ pom.xml | 55 ++++++++++++++++++++++++++++- src/main/ruby/jruby/rack/version.rb | 2 +- 3 files changed, 65 insertions(+), 2 deletions(-) diff --git a/History.md b/History.md index a5cbf0f0..0d423fcc 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,13 @@ +## 1.1.17 (30/12/14) + +This release changes deployment from codehaus.org to oss.sonatype.org for artifacts. + +- just keep the jruby-home when set by jruby to "uri:classsloader:..." JRuby 9k +- support configuration of `Response.swallow_client_abort?` (#186) +- better client EOF (socket abort "Broken pipe") detection in Response + we're now "officially" handling Jetty and maybe a bunch of others +- allow PATCH verb to be processed by the ruby application (#184) + ## 1.1.16 (14/08/14) - deal with `real_path` (file-system) layout regression introduced in 1.1.15 diff --git a/pom.xml b/pom.xml index f5b7b133..27f08676 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ org.jruby.rack jruby-rack - 1.1.17-SNAPSHOT + 1.1.17 JRuby-Rack http://github.com/jruby/jruby-rack/ @@ -295,6 +295,59 @@ + + release + + + performRelease + true + + + + + + org.apache.maven.plugins + maven-source-plugin + 2.4 + + + attach-sources + + jar-no-fork + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.10.1 + + + attach-javadocs + + jar + + + + + + org.apache.maven.plugins + maven-gpg-plugin + 1.5 + + + sign-artifacts + verify + + sign + + + + + + + diff --git a/src/main/ruby/jruby/rack/version.rb b/src/main/ruby/jruby/rack/version.rb index cb4105b8..a73e88bd 100644 --- a/src/main/ruby/jruby/rack/version.rb +++ b/src/main/ruby/jruby/rack/version.rb @@ -7,6 +7,6 @@ module JRuby module Rack - VERSION = '1.1.17.SNAPSHOT' + VERSION = '1.1.17' end end From 338ce40d1c302f89e1d7924ac798d1205273795d Mon Sep 17 00:00:00 2001 From: kares Date: Tue, 30 Dec 2014 11:55:43 +0100 Subject: [PATCH 02/27] update to next dev snapshot + re-arrange release steps --- Rakefile | 30 ++++++++++++------ pom.xml | 47 ++++++++++++----------------- src/main/ruby/jruby/rack/version.rb | 2 +- 3 files changed, 41 insertions(+), 38 deletions(-) diff --git a/Rakefile b/Rakefile index e69b93fc..7b521bfd 100644 --- a/Rakefile +++ b/Rakefile @@ -24,27 +24,31 @@ end GENERATED = FileList.new namespace :clean do - desc "Remove generated files" + desc "Remove generated files (only)" task :generated do GENERATED.each { |fn| rm_r fn rescue nil } end + desc "Remove lib/*.jar (test) dependencies" + task :lib do + rm_r 'target/lib' rescue nil + end end directory 'target/classes' desc "Compile classes" -task(:compile => 'target/classes') { sh 'mvn compile' } +task(:compile => 'target/classes') { sh 'mvn compile -Dmdep.skip=true' } directory 'target/test-classes' desc "Compile test classes" -task(:test_compile => 'target/test-classes') { sh 'mvn test-compile' } +task(:test_compile => 'target/test-classes') { sh 'mvn test-compile -Dmdep.skip=true' } desc "Copy .jar dependencies for (local) testing" -task(:test_jars) { sh 'mvn test-compile -P jars' } +task(:test_jars) { sh 'mvn test-compile' } task(:test_prepare => ['target/classes', 'target/test-classes']) do - sh 'mvn compile test-compile -P jars' + sh 'mvn test-compile' end desc "Unpack the rack gem" @@ -96,7 +100,7 @@ end namespace :resources do desc "Copy (and generate) resources" task :copy => :resources do - sh 'mvn process-resources' + sh 'mvn process-resources -Dmdep.skip=true' end desc "Generate test resources" task :test => :test_resources @@ -219,16 +223,24 @@ task :release_checks do "Please run `mvn install' to bring the two files in sync." end - puts "Release looks ready to go!" + puts "release #{GEM_VERSION} looks ready to go ..." end desc "Release the gem to rubygems and jar to repository.codehaus.org" -task :release => [:release_checks, :clean, :gem] do +task :release => [:release_checks, :clean] do + args = '' + args << "-Dgpg.keyname=#{ENV['GPG_KEYNAME']} " if ENV['GPG_KEYNAME'] + + sh "mvn -Prelease #{args} -DupdateReleaseInfo=true clean deploy" + sh "git tag #{GEM_VERSION}" - sh "mvn deploy -DupdateReleaseInfo=true" + + ENV['SKIP_SPECS'] = 'true'; Rake::Task['gem'].invoke sh "gem push target/jruby-rack-#{GEM_VERSION}.gem" + git_branch = `git branch | sed -n '/\* /s///p'`.chomp sh "git push --tags #{ENV['GIT_REMOTE'] || 'origin'} #{git_branch}" + puts "released JRuby-Rack #{GEM_VERSION} update next SNAPSHOT version using `rake update_version`" end diff --git a/pom.xml b/pom.xml index 27f08676..79c3aa8a 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ org.jruby.rack jruby-rack - 1.1.17 + 1.1.18-SNAPSHOT JRuby-Rack http://github.com/jruby/jruby-rack/ @@ -201,6 +201,24 @@ maven-help-plugin 2.2 + + org.apache.maven.plugins + maven-dependency-plugin + 2.9 + + + process-sources + + copy-dependencies + + + + ${project.build.directory}/lib + org.jruby,rubygems + + + + de.saumya.mojo gem-maven-plugin @@ -268,33 +286,6 @@ - - jars - - true - - - - - org.apache.maven.plugins - maven-dependency-plugin - 2.8 - - - process-sources - - copy-dependencies - - - ${project.build.directory}/lib - org.jruby - - - - - - - release diff --git a/src/main/ruby/jruby/rack/version.rb b/src/main/ruby/jruby/rack/version.rb index a73e88bd..a32635a7 100644 --- a/src/main/ruby/jruby/rack/version.rb +++ b/src/main/ruby/jruby/rack/version.rb @@ -7,6 +7,6 @@ module JRuby module Rack - VERSION = '1.1.17' + VERSION = '1.1.18.SNAPSHOT' end end From 1231b12aeb193e9cfe14615443338f484a9b3d55 Mon Sep 17 00:00:00 2001 From: kares Date: Tue, 30 Dec 2014 15:08:13 +0100 Subject: [PATCH 03/27] README revisited --- README.md | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 39b73376..30dddeb4 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,18 @@ # JRuby-Rack JRuby-Rack is a lightweight adapter for the Java Servlet environment that allows -any Rack-based application to run unmodified in a Java Servlet container. +any (Ruby) Rack-based application to run unmodified in a Java Servlet container. JRuby-Rack supports Rails as well as any Rack-compatible Ruby web framework. -For more information on Rack, visit http://rack.rubyforge.org. +For more information on Rack, visit http://rack.github.io/. -[![Build Status][0]](http://travis-ci.org/jruby/jruby-rack) +[![Gem Version](https://badge.fury.io/rb/jruby-rack.png)][8] +[![Build Status][9]](http://travis-ci.org/jruby/jruby-rack) ## Compatibility -JRuby-Rack 1.1.x aims to be compatible with JRuby 1.6 as well as 1.7 (we do -recommend 1.7), Generally, any container that supports Java Servlet >= 2.5 -(JavaEE 5) specification is supported. +JRuby-Rack 1.1.x aims to be compatible with JRuby >= 1.6.4 (we recommend 1.7.x), +Generally, any container that supports Java Servlet >= 2.5 (JEE 5) is supported. ## Getting Started @@ -326,11 +326,12 @@ package and push the .jar every time a commit changes a source file). ## Support Please use [github][4] to file bugs, patches and/or pull requests. -More information at the [wiki][5] or ask us at the #jruby IRC channel. +More information at the [wiki][5] or ask us at **#jruby**'s IRC channel. -[0]: https://secure.travis-ci.org/jruby/jruby-rack.png?branch=master -[1]: http://caldersphere.rubyforge.org/warbler -[2]: http://repository.codehaus.org/org/jruby/rack/jruby-rack/ +[1]: https://github.com/jruby/warbler#warbler-- +[2]: https://oss.sonatype.org/content/repositories/releases/org/jruby/rack/jruby-rack/ [3]: https://github.com/trinidad/trinidad [4]: https://github.com/jruby/jruby-rack/issues [5]: https://wiki.github.com/jruby/jruby-rack +[8]: http://badge.fury.io/rb/jruby-rack +[9]: https://secure.travis-ci.org/jruby/jruby-rack.png?branch=1.1-stable From 4a43caecab3e729ee331c15da320a48f329d6178 Mon Sep 17 00:00:00 2001 From: kares Date: Mon, 5 Jan 2015 21:16:21 +0100 Subject: [PATCH 04/27] [travis-ci] explicit jruby 1.7 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 9f8b1017..447706e6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,7 @@ rvm: # @see ruby/rack/application_spec.rb for an explanation on this #- jruby-18mode #- jruby-19mode - - jruby + - jruby-1.7.16 - jruby-head jdk: - openjdk6 From 10400fe969496f8b974590e565fe95bd6ddecadc Mon Sep 17 00:00:00 2001 From: kares Date: Sun, 4 Jan 2015 20:32:13 +0100 Subject: [PATCH 05/27] add a (latest) rack-compatibility spec in params parsing --- src/spec/ruby/rack/handler/servlet_spec.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/spec/ruby/rack/handler/servlet_spec.rb b/src/spec/ruby/rack/handler/servlet_spec.rb index 0256b1bb..889cef1f 100644 --- a/src/spec/ruby/rack/handler/servlet_spec.rb +++ b/src/spec/ruby/rack/handler/servlet_spec.rb @@ -975,6 +975,26 @@ def servlet.create_env(servlet_env) rack_request.request_method.should == 'PUT' end + it "does not truncate query strings containing semi-colons (Rack-compat)" do + servlet_request.setMethod 'GET' + servlet_request.setContextPath '/' + servlet_request.setPathInfo '/path' + servlet_request.setRequestURI '/home/path' + servlet_request.setQueryString 'foo=bar&quux=b;la' + # Query params : + servlet_request.addParameter('foo', 'bar') + servlet_request.addParameter('quux', 'b;la') + + env = servlet.create_env(servlet_env) + rack_request = Rack::Request.new(env) + + rack_request.GET.should == { "foo" => "bar", "quux" => "b;la" } + rack_request.POST.should == {} + rack_request.params.should == { "foo" => "bar", "quux" => "b;la" } + + rack_request.query_string.should == 'foo=bar&quux=b;la' + end + it "sets cookies from servlet requests" do cookies = [] cookies << javax.servlet.http.Cookie.new('foo', 'bar') From 65b564b10084c47bb1131befc24b0ed660832f5c Mon Sep 17 00:00:00 2001 From: kares Date: Mon, 5 Jan 2015 11:14:46 +0100 Subject: [PATCH 06/27] rack_release spec helper --- src/spec/ruby/spec_helper.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/spec/ruby/spec_helper.rb b/src/spec/ruby/spec_helper.rb index 3baefcb2..6a44b4d3 100644 --- a/src/spec/ruby/spec_helper.rb +++ b/src/spec/ruby/spec_helper.rb @@ -88,6 +88,12 @@ def servlet_30? end private :servlet_30? + def rack_release(at_least = nil) + require 'rack'; release = Rack.release + at_least.nil? ? release : release >= at_least + end + private :rack_release + @@raise_logger = nil def raise_logger From df5b011c432280776762496aad346730c9850f94 Mon Sep 17 00:00:00 2001 From: kares Date: Mon, 5 Jan 2015 20:21:04 +0100 Subject: [PATCH 07/27] work-around rack 1.6.0 reporting Rack.release as 1.5 :sadpanda: --- src/spec/ruby/spec_helper.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/src/spec/ruby/spec_helper.rb b/src/spec/ruby/spec_helper.rb index 6a44b4d3..58a5100d 100644 --- a/src/spec/ruby/spec_helper.rb +++ b/src/spec/ruby/spec_helper.rb @@ -90,6 +90,7 @@ def servlet_30? def rack_release(at_least = nil) require 'rack'; release = Rack.release + release = '1.6' if Gem.loaded_specs['rack'].version.to_s == '1.6.0' at_least.nil? ? release : release >= at_least end private :rack_release From 65f6bc803092fdcb4917a1a0e3b77126436e666b Mon Sep 17 00:00:00 2001 From: kares Date: Mon, 5 Jan 2015 18:21:54 +0100 Subject: [PATCH 08/27] improved rack-compatibility for our "pure" servlet-env request env parsing impl ... we'll now raise a TypeError just like rack does when it detects invalid parameters --- .../ruby/rack/handler/servlet/servlet_env.rb | 59 +++++++++++++++++-- src/spec/ruby/rack/handler/servlet_spec.rb | 27 +++++++++ 2 files changed, 80 insertions(+), 6 deletions(-) diff --git a/src/main/ruby/rack/handler/servlet/servlet_env.rb b/src/main/ruby/rack/handler/servlet/servlet_env.rb index 4f557773..95568710 100644 --- a/src/main/ruby/rack/handler/servlet/servlet_env.rb +++ b/src/main/ruby/rack/handler/servlet/servlet_env.rb @@ -50,6 +50,12 @@ def load_env_key(env, key) # @private POST_PARAM_METHODS = [ 'POST', 'PUT', 'DELETE' ].freeze + if defined? Rack::Utils::ParameterTypeError + ParameterTypeError = Rack::Utils::ParameterTypeError + else + ParameterTypeError = TypeError + end + # Load parameters into the (Rack) env from the Servlet API. # using javax.servlet.http.HttpServletRequest#getParameterMap def load_parameters @@ -65,7 +71,7 @@ def load_parameters @servlet_env.getParameterMap.each do |key, val| # String, String[] val = [''] if val.nil? # e.g. buggy Jetty 6 val = [''] if val.length == 1 && val[0].nil? - + if ( q_vals = query_values(key) ) || get_only if q_vals.length != val.length # some are GET params some POST params @@ -93,6 +99,20 @@ def load_parameters @env[ FORM_HASH ] = form_hash end + def [](key) + value = super(key) + if key.eql? QUERY_HASH + if @parameter_error ||= nil + raise @parameter_error + end + end + value + end + public :[] + + # @private + KEY_SEP = /([^\[\]]*)(?:\[(.*?)\])?/ + # Store the parameter into the given Hash. # By default this is performed in a Rack compatible way and thus # some parameter values might get "lost" - it only accepts multiple @@ -102,12 +122,33 @@ def load_parameters # @param val the value(s) in a array-like structure # @param hash the Hash to store the name, value pair def store_parameter(key, val, hash) - # Rack::Utils.parse_nested_query behaviour - # for 'foo=bad&foo=bar' does { 'foo' => 'bar' } - if key[-2, 2] == '[]' # foo[]=f1&foo[]=f2 - hash[ key[0...-2] ] = val.to_a # String[] + # emulating Rack::Utils.parse_nested_query behavior + + if match = key.match(KEY_SEP) + n_key = match[1]; sub = match[2] else - hash[ key ] = val[ val.length - 1 ] # last + n_key = key; sub = nil # normalized-key[ sub-key ] + end + + if sub + if sub.empty? # e.g. foo[]=1&foo[]=2 + if arr = hash[ n_key ] + return mark_parameter_error "expected Array (got #{arr.class}) for param `#{n_key}'" unless arr.is_a?(Array) + hash[ n_key ] = arr + val.to_a; return + end + hash[ n_key ] = val.to_a # String[] + else # foo[bar]=rrr&foo[baz]=zzz + v = val[ val.length - 1 ] # last + if hsh = hash[ n_key ] + return mark_parameter_error "expected Hash (got #{hsh.class}) for param `#{n_key}'" unless hsh.is_a?(Hash) + hsh[ sub ] = v + else + hash[ n_key ] = { sub => v } + end + end + else + # for 'foo=bad&foo=bar' does { 'foo' => 'bar' } + hash[ n_key ] = val[ val.length - 1 ] # last end end @@ -149,6 +190,12 @@ def parse_query_string Java::JavaxServletHttp::HttpUtils.parseQueryString(query_string) end + def mark_parameter_error(msg) + raise ParameterTypeError, msg + rescue ParameterTypeError => e + @parameter_error = e + end + end end end diff --git a/src/spec/ruby/rack/handler/servlet_spec.rb b/src/spec/ruby/rack/handler/servlet_spec.rb index 889cef1f..1d7ef81d 100644 --- a/src/spec/ruby/rack/handler/servlet_spec.rb +++ b/src/spec/ruby/rack/handler/servlet_spec.rb @@ -363,6 +363,33 @@ def getAttributeNames expect( env['org.apache.internal'] ).to be true end + it "raises if nested request parameters are broken (Rack-compat)" do + servlet_request = @servlet_request + servlet_request.setMethod 'GET' + servlet_request.setContextPath '/' + servlet_request.setPathInfo '/path' + servlet_request.setRequestURI '/home/path' + servlet_request.setQueryString 'foo[]=0&foo[bar]=1' + servlet_request.addParameter('foo[]', '0') + servlet_request.addParameter('foo[bar]', '1') + + env = servlet.create_env(@servlet_env) + rack_request = Rack::Request.new(env) + + # Rack::Utils::ParameterTypeError (< TypeError) since 1.6.0 + if Rack::Utils.const_defined? :ParameterTypeError + error = Rack::Utils::ParameterTypeError + else + error = TypeError + end + + expect { rack_request.GET }.to raise_error(error, "expected Hash (got Array) for param `foo'") + rack_request.POST.should == {} + expect { rack_request.params }.to raise_error(error, "expected Hash (got Array) for param `foo'") if rack_release('1.6') + + rack_request.query_string.should == 'foo[]=0&foo[bar]=1' + end + end shared_examples "(eager)rack-env" do From 2c4650e0e7e8aa55eeae5b73991616c155be4266 Mon Sep 17 00:00:00 2001 From: kares Date: Mon, 5 Jan 2015 21:12:20 +0100 Subject: [PATCH 09/27] even more compatibility with rack's parse_nested_query logic for "pure" servlet-env --- .../ruby/rack/handler/servlet/servlet_env.rb | 7 +- src/spec/ruby/rack/handler/servlet_spec.rb | 66 +++++++++++++++++++ 2 files changed, 69 insertions(+), 4 deletions(-) diff --git a/src/main/ruby/rack/handler/servlet/servlet_env.rb b/src/main/ruby/rack/handler/servlet/servlet_env.rb index 95568710..0cbb9d34 100644 --- a/src/main/ruby/rack/handler/servlet/servlet_env.rb +++ b/src/main/ruby/rack/handler/servlet/servlet_env.rb @@ -111,7 +111,7 @@ def [](key) public :[] # @private - KEY_SEP = /([^\[\]]*)(?:\[(.*?)\])?/ + KEY_SEP = /([^\[\]]+)(?:\[(.*)\])?/ # Store the parameter into the given Hash. # By default this is performed in a Rack compatible way and thus @@ -138,12 +138,11 @@ def store_parameter(key, val, hash) end hash[ n_key ] = val.to_a # String[] else # foo[bar]=rrr&foo[baz]=zzz - v = val[ val.length - 1 ] # last if hsh = hash[ n_key ] return mark_parameter_error "expected Hash (got #{hsh.class}) for param `#{n_key}'" unless hsh.is_a?(Hash) - hsh[ sub ] = v + store_parameter(sub, val, hsh) else - hash[ n_key ] = { sub => v } + hash[ n_key ] = { sub => val[ val.length - 1 ] } end end else diff --git a/src/spec/ruby/rack/handler/servlet_spec.rb b/src/spec/ruby/rack/handler/servlet_spec.rb index 1d7ef81d..3f4d232e 100644 --- a/src/spec/ruby/rack/handler/servlet_spec.rb +++ b/src/spec/ruby/rack/handler/servlet_spec.rb @@ -363,6 +363,72 @@ def getAttributeNames expect( env['org.apache.internal'] ).to be true end + it "parses strange request parameters (Rack-compat)" do + servlet_request = @servlet_request + servlet_request.setMethod 'GET' + servlet_request.setContextPath '/' + servlet_request.setPathInfo '/path' + servlet_request.setRequestURI '/home/path' + + servlet_request.setQueryString 'foo]=0&bar[=1&baz_=2&[meh=3' + servlet_request.addParameter('foo]', '0') + servlet_request.addParameter('bar[', '1') + servlet_request.addParameter('baz_', '2') + servlet_request.addParameter('[meh', '3') + + env = servlet.create_env(@servlet_env) + rack_request = Rack::Request.new(env) + + # Rack (1.5.2) does it as : + # { "foo" => "0", "bar" => nil, "baz_" => "2", "meh" => "3" } + # 1.6.0 : + # { "foo" => "0", "bar[" => "1", "baz_" => "2", "meh" => "3" } + + expect( rack_request.GET['foo'] ).to eql('0') + expect( rack_request.GET['baz_'] ).to eql('2') + + if rack_release('1.6') + # expect( rack_request.GET['bar['] ).to eql('1') + else + expect( rack_request.GET.key?('bar') ).to be true + end + expect( rack_request.GET['meh'] ).to eql('3') + + expect( rack_request.query_string ).to eql 'foo]=0&bar[=1&baz_=2&[meh=3' + end + + it "parses nestedx request parameters (Rack-compat)" do + servlet_request = @servlet_request + servlet_request.setMethod 'GET' + servlet_request.setContextPath '/' + servlet_request.setPathInfo '/path' + servlet_request.setRequestURI '/home/path' + + servlet_request.setQueryString 'foo[bar]=0&foo[baz]=1&foo[bar]=2&foo[meh[]]=x&foo[meh[]]=42&huh[1]=b&huh[0]=a' + servlet_request.addParameter('foo[bar]', '0') + servlet_request.addParameter('foo[baz]', '1') + servlet_request.addParameter('foo[bar]', '2') + servlet_request.addParameter('foo[meh[]]', 'x') + servlet_request.addParameter('foo[meh[]]', '42') + servlet_request.addParameter('huh[1]', 'b') + servlet_request.addParameter('huh[0]', 'a') + + env = servlet.create_env(@servlet_env) + rack_request = Rack::Request.new(env) + + #params = { "foo" => { "bar" => "2", "baz" => "1", "meh" => [ nil, nil ] }, "huh" => { "1" => "b", "0" => "a" } } + #expect( rack_request.GET ).to eql(params) + + expect( rack_request.GET['foo']['bar'] ).to eql('2') + expect( rack_request.GET['foo']['baz'] ).to eql('1') + expect( rack_request.params['foo']['meh'] ).to be_a Array + expect( rack_request.params['huh'] ).to eql({ "1" => "b", "0" => "a" }) + + expect( rack_request.POST ).to eql Hash.new + + expect( rack_request.query_string ).to eql 'foo[bar]=0&foo[baz]=1&foo[bar]=2&foo[meh[]]=x&foo[meh[]]=42&huh[1]=b&huh[0]=a' + end + it "raises if nested request parameters are broken (Rack-compat)" do servlet_request = @servlet_request servlet_request.setMethod 'GET' From 6cb58dba2b5382246d3e9e1afd2b1e3d93e44f8d Mon Sep 17 00:00:00 2001 From: kares Date: Mon, 5 Jan 2015 09:44:36 +0100 Subject: [PATCH 10/27] re-arrange JRuby::Rack::ErrorApp internals --- src/main/ruby/jruby/rack/error_app.rb | 33 +++++++++++++-------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/src/main/ruby/jruby/rack/error_app.rb b/src/main/ruby/jruby/rack/error_app.rb index 4a320aa6..e12d90f3 100644 --- a/src/main/ruby/jruby/rack/error_app.rb +++ b/src/main/ruby/jruby/rack/error_app.rb @@ -75,13 +75,13 @@ def serve(code, path, env) body = env['REQUEST_METHOD'] == 'HEAD' ? [] : FileBody.new(path, size = File.size?(path)) response = [ code, headers, body ] - size ||= ::Rack::Utils.bytesize(File.read(path)) if defined?(::Rack::Utils) + size ||= ::Rack::Utils.bytesize(File.read(path)) if defined?(::Rack::Utils.bytesize) response[1]['Content-Length'] = size.to_s if size response end - private + protected def accept_html?(env) http_accept = env['HTTP_ACCEPT'].to_s @@ -112,15 +112,6 @@ def respond(status = nil, body = nil, headers = DEFAULT_HEADERS) [ status, headers, body ? [ body ] : [] ] end - def expand_path(path, root = self.root) - exp_path = File.join(root, path) - begin - return exp_path if File.file?(exp_path) && File.readable?(exp_path) - rescue SystemCallError - nil - end - end - class FileBody attr_reader :path, :size @@ -145,14 +136,22 @@ def each end - def self.silent_require(feature) - require feature - rescue LoadError - nil + private + + def expand_path(path, root = self.root) + exp_path = File.join(root, path) + begin + return exp_path if File.file?(exp_path) && File.readable?(exp_path) + rescue SystemCallError + nil + end end - silent_require 'rack/utils' - silent_require 'rack/mime' + begin + require 'rack/utils' + require 'rack/mime' + rescue LoadError + end end end From c2b147737287026415f6b059d16ca6e8fa816a35 Mon Sep 17 00:00:00 2001 From: kares Date: Mon, 5 Jan 2015 22:13:48 +0100 Subject: [PATCH 11/27] use Rack::Utils.best_q_match in ErrorApp if available, also accepts_html? is private API --- src/main/ruby/jruby/rack/error_app.rb | 32 ++++++++++++++++++--------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/src/main/ruby/jruby/rack/error_app.rb b/src/main/ruby/jruby/rack/error_app.rb index e12d90f3..3e7d27d3 100644 --- a/src/main/ruby/jruby/rack/error_app.rb +++ b/src/main/ruby/jruby/rack/error_app.rb @@ -83,15 +83,6 @@ def serve(code, path, env) protected - def accept_html?(env) - http_accept = env['HTTP_ACCEPT'].to_s - if ! http_accept.empty? # NOTE: some really stupid matching for now : - !! ( http_accept.index('text/html') || http_accept.index('*/*') ) - else - nil - end - end - def map_error_code(exc) cause = exc.respond_to?(:cause) ? exc.cause : nil if UNAVAILABLE_EXCEPTIONS.any? { |type| exc.kind_of?(type) } @@ -150,7 +141,28 @@ def expand_path(path, root = self.root) begin require 'rack/utils' require 'rack/mime' - rescue LoadError + rescue LoadError; end + + if defined? Rack::Utils.best_q_match + + def accepts_html?(env) + Rack::Utils.best_q_match(env['HTTP_ACCEPT'], %w[text/html]) + rescue + http_accept?(env, 'text/html') + end + + else + + def accepts_html?(env) + http_accept?(env, 'text/html') || http_accept?(env, '*/*') + end + + end + alias accept_html? accepts_html? # JRuby-Rack 1.1 compatibility + + def http_accept?(env, mime) + http_accept = env['HTTP_ACCEPT'].to_s + http_accept.empty? ? nil : !! http_accept.index(mime) end end From 474aafcbdd953a8eaf403a9b27a1561a5ec5a9b8 Mon Sep 17 00:00:00 2001 From: kares Date: Tue, 6 Jan 2015 13:29:36 +0100 Subject: [PATCH 12/27] [travis-ci] fix jruby excludes (using explicit jruby-1.7.x version number now) --- .travis.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 447706e6..eb83398f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -100,28 +100,28 @@ matrix: env: JRUBY_OPTS="$JRUBY_OPTS" JAVA_OPTS="-Djruby.version=$JRUBY_VERSION" jdk: openjdk6 ## rails 4.0 does not run on --1.8 - - rvm: jruby + - rvm: jruby-1.7.16 gemfile: gemfiles/rails40.gemfile env: JRUBY_OPTS="--1.8 $JRUBY_OPTS" jdk: openjdk6 - - rvm: jruby + - rvm: jruby-1.7.16 gemfile: gemfiles/rails40.gemfile env: JRUBY_OPTS="--1.8 $JRUBY_OPTS" jdk: oraclejdk7 - - rvm: jruby + - rvm: jruby-1.7.16 gemfile: gemfiles/rails40.gemfile env: JRUBY_OPTS="--1.8 $JRUBY_OPTS" jdk: oraclejdk8 ## rails 4.1 won't run on --1.8 - - rvm: jruby + - rvm: jruby-1.7.16 gemfile: gemfiles/rails41.gemfile env: JRUBY_OPTS="--1.8 $JRUBY_OPTS" jdk: openjdk6 - - rvm: jruby + - rvm: jruby-1.7.16 gemfile: gemfiles/rails41.gemfile env: JRUBY_OPTS="--1.8 $JRUBY_OPTS" jdk: oraclejdk7 - - rvm: jruby + - rvm: jruby-1.7.16 gemfile: gemfiles/rails41.gemfile env: JRUBY_OPTS="--1.8 $JRUBY_OPTS" jdk: oraclejdk8 From efb74bd0561eb0855c6602642b7a2fe277826984 Mon Sep 17 00:00:00 2001 From: kares Date: Sat, 10 Jan 2015 15:01:14 +0100 Subject: [PATCH 13/27] fix compatibility for newly added (servlet-env) specs with all (supported) rack versions --- src/spec/ruby/rack/handler/servlet_spec.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/spec/ruby/rack/handler/servlet_spec.rb b/src/spec/ruby/rack/handler/servlet_spec.rb index 3f4d232e..5e488d2e 100644 --- a/src/spec/ruby/rack/handler/servlet_spec.rb +++ b/src/spec/ruby/rack/handler/servlet_spec.rb @@ -412,6 +412,7 @@ def getAttributeNames servlet_request.addParameter('foo[meh[]]', '42') servlet_request.addParameter('huh[1]', 'b') servlet_request.addParameter('huh[0]', 'a') + set_rack_input @servlet_env # due rack_request.POST env = servlet.create_env(@servlet_env) rack_request = Rack::Request.new(env) @@ -438,6 +439,7 @@ def getAttributeNames servlet_request.setQueryString 'foo[]=0&foo[bar]=1' servlet_request.addParameter('foo[]', '0') servlet_request.addParameter('foo[bar]', '1') + set_rack_input @servlet_env # due rack_request.POST env = servlet.create_env(@servlet_env) rack_request = Rack::Request.new(env) @@ -1077,6 +1079,7 @@ def servlet.create_env(servlet_env) # Query params : servlet_request.addParameter('foo', 'bar') servlet_request.addParameter('quux', 'b;la') + set_rack_input servlet_env # due rack_request.POST env = servlet.create_env(servlet_env) rack_request = Rack::Request.new(env) From d4169a6f4dbc4c33153157265418d8562d81b898 Mon Sep 17 00:00:00 2001 From: kares Date: Sat, 10 Jan 2015 16:05:42 +0100 Subject: [PATCH 14/27] [travis-ci ] make sure 1.1 is kept backwards (JRuby 1.6.x) compatible --- .travis.yml | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 82 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index eb83398f..c362b438 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,10 +8,7 @@ branches: - 1.1-stable - maintenance-1.1.13 rvm: - # NOTE: do not use jruby-19mode otherwise some specs might fail - # @see ruby/rack/application_spec.rb for an explanation on this - #- jruby-18mode - #- jruby-19mode + - jruby-1.6.8 - jruby-1.7.16 - jruby-head jdk: @@ -99,6 +96,63 @@ matrix: gemfile: gemfiles/rails41.gemfile env: JRUBY_OPTS="$JRUBY_OPTS" JAVA_OPTS="-Djruby.version=$JRUBY_VERSION" jdk: openjdk6 + ## avoid jruby-1.6.8 with JDK8 : + - rvm: jruby-1.6.8 + gemfile: Gemfile + env: JRUBY_OPTS="--1.8 $JRUBY_OPTS" + jdk: oraclejdk8 + - rvm: jruby-1.6.8 + gemfile: Gemfile + env: JRUBY_OPTS="$JRUBY_OPTS" JAVA_OPTS="-Djruby.version=$JRUBY_VERSION" + jdk: oraclejdk8 + - rvm: jruby-1.6.8 + gemfile: gemfiles/rails23.gemfile + env: JRUBY_OPTS="--1.8 $JRUBY_OPTS" + jdk: oraclejdk8 + - rvm: jruby-1.6.8 + gemfile: gemfiles/rails23.gemfile + env: JRUBY_OPTS="$JRUBY_OPTS" JAVA_OPTS="-Djruby.version=$JRUBY_VERSION" + jdk: oraclejdk8 + - rvm: jruby-1.6.8 + gemfile: gemfiles/rails30.gemfile + env: JRUBY_OPTS="--1.8 $JRUBY_OPTS" + jdk: oraclejdk8 + - rvm: jruby-1.6.8 + gemfile: gemfiles/rails30.gemfile + env: JRUBY_OPTS="$JRUBY_OPTS" JAVA_OPTS="-Djruby.version=$JRUBY_VERSION" + jdk: oraclejdk8 + - rvm: jruby-1.6.8 + gemfile: gemfiles/rails31.gemfile + env: JRUBY_OPTS="--1.8 $JRUBY_OPTS" + jdk: oraclejdk8 + - rvm: jruby-1.6.8 + gemfile: gemfiles/rails31.gemfile + env: JRUBY_OPTS="$JRUBY_OPTS" JAVA_OPTS="-Djruby.version=$JRUBY_VERSION" + jdk: oraclejdk8 + - rvm: jruby-1.6.8 + gemfile: gemfiles/rails32.gemfile + env: JRUBY_OPTS="--1.8 $JRUBY_OPTS" + jdk: oraclejdk8 + - rvm: jruby-1.6.8 + gemfile: gemfiles/rails32.gemfile + env: JRUBY_OPTS="$JRUBY_OPTS" JAVA_OPTS="-Djruby.version=$JRUBY_VERSION" + jdk: oraclejdk8 + - rvm: jruby-1.6.8 + gemfile: gemfiles/rails40.gemfile + env: JRUBY_OPTS="--1.8 $JRUBY_OPTS" + jdk: oraclejdk8 + - rvm: jruby-1.6.8 + gemfile: gemfiles/rails40.gemfile + env: JRUBY_OPTS="$JRUBY_OPTS" JAVA_OPTS="-Djruby.version=$JRUBY_VERSION" + jdk: oraclejdk8 + - rvm: jruby-1.6.8 + gemfile: gemfiles/rails41.gemfile + env: JRUBY_OPTS="--1.8 $JRUBY_OPTS" + jdk: oraclejdk8 + - rvm: jruby-1.6.8 + gemfile: gemfiles/rails41.gemfile + env: JRUBY_OPTS="$JRUBY_OPTS" JAVA_OPTS="-Djruby.version=$JRUBY_VERSION" + jdk: oraclejdk8 ## rails 4.0 does not run on --1.8 - rvm: jruby-1.7.16 gemfile: gemfiles/rails40.gemfile @@ -112,6 +166,18 @@ matrix: gemfile: gemfiles/rails40.gemfile env: JRUBY_OPTS="--1.8 $JRUBY_OPTS" jdk: oraclejdk8 + - rvm: jruby-1.6.8 + gemfile: gemfiles/rails40.gemfile + env: JRUBY_OPTS="--1.8 $JRUBY_OPTS" + jdk: openjdk6 + - rvm: jruby-1.6.8 + gemfile: gemfiles/rails40.gemfile + env: JRUBY_OPTS="--1.8 $JRUBY_OPTS" + jdk: oraclejdk7 + - rvm: jruby-1.6.8 + gemfile: gemfiles/rails40.gemfile + env: JRUBY_OPTS="--1.8 $JRUBY_OPTS" + jdk: oraclejdk8 ## rails 4.1 won't run on --1.8 - rvm: jruby-1.7.16 gemfile: gemfiles/rails41.gemfile @@ -125,6 +191,18 @@ matrix: gemfile: gemfiles/rails41.gemfile env: JRUBY_OPTS="--1.8 $JRUBY_OPTS" jdk: oraclejdk8 + - rvm: jruby-1.6.8 + gemfile: gemfiles/rails41.gemfile + env: JRUBY_OPTS="--1.8 $JRUBY_OPTS" + jdk: openjdk6 + - rvm: jruby-1.6.8 + gemfile: gemfiles/rails41.gemfile + env: JRUBY_OPTS="--1.8 $JRUBY_OPTS" + jdk: oraclejdk7 + - rvm: jruby-1.6.8 + gemfile: gemfiles/rails41.gemfile + env: JRUBY_OPTS="--1.8 $JRUBY_OPTS" + jdk: oraclejdk8 ## rails 4.0 does not run on --1.8 (jruby-head) #- rvm: jruby-head # gemfile: gemfiles/rails40.gemfile From 8fe9a6867bcf455ffe3ad97642aa82b5aee8e875 Mon Sep 17 00:00:00 2001 From: kares Date: Sat, 10 Jan 2015 17:11:27 +0100 Subject: [PATCH 15/27] do not care about "OpenSSL::Random requires the jruby-openssl gem" on 1.6.8 --- src/spec/ruby/cgi/session/java_servlet_store_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/spec/ruby/cgi/session/java_servlet_store_spec.rb b/src/spec/ruby/cgi/session/java_servlet_store_spec.rb index 5a1d99c2..602dbb2a 100644 --- a/src/spec/ruby/cgi/session/java_servlet_store_spec.rb +++ b/src/spec/ruby/cgi/session/java_servlet_store_spec.rb @@ -171,6 +171,6 @@ def hmac(key, data) @session.should_receive(:getLastAccessedTime).and_return 123 @session.should_receive(:setAttribute).with("__rails_secret", "abcrandom123") @dbman.generate_digest("key").should == hmac("abcrandom123", "key") - end + end unless JRUBY_VERSION < '1.7.0' end end From 7b4e8892fdd4e22518c4d2022cf140ce43a7f173 Mon Sep 17 00:00:00 2001 From: kares Date: Sat, 10 Jan 2015 17:31:27 +0100 Subject: [PATCH 16/27] [travis-ci] more JRuby 1.6.8 excludes + allow failures (still useful for spec regressions) --- .travis.yml | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index c362b438..1f07ff7d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -36,7 +36,7 @@ before_install: - ((echo $BUNDLE_GEMFILE | grep rails23) && jruby --1.9 -S gem update --system 1.8.29) || true matrix: allow_failures: - #- rvm: jruby-head + - rvm: jruby-1.6.8 #- gemfile: gemfiles/rails41.gemfile exclude: ## avoid jruby-head with JDK6 : @@ -166,6 +166,7 @@ matrix: gemfile: gemfiles/rails40.gemfile env: JRUBY_OPTS="--1.8 $JRUBY_OPTS" jdk: oraclejdk8 + ## rails 4.0 won't run on JRuby 1.6 - rvm: jruby-1.6.8 gemfile: gemfiles/rails40.gemfile env: JRUBY_OPTS="--1.8 $JRUBY_OPTS" @@ -176,7 +177,19 @@ matrix: jdk: oraclejdk7 - rvm: jruby-1.6.8 gemfile: gemfiles/rails40.gemfile - env: JRUBY_OPTS="--1.8 $JRUBY_OPTS" + env: JRUBY_OPTS="$JRUBY_OPTS" JAVA_OPTS="-Djruby.version=$JRUBY_VERSION" + jdk: oraclejdk8 + - rvm: jruby-1.6.8 + gemfile: gemfiles/rails40.gemfile + env: JRUBY_OPTS="$JRUBY_OPTS" JAVA_OPTS="-Djruby.version=$JRUBY_VERSION" + jdk: openjdk6 + - rvm: jruby-1.6.8 + gemfile: gemfiles/rails40.gemfile + env: JRUBY_OPTS="$JRUBY_OPTS" JAVA_OPTS="-Djruby.version=$JRUBY_VERSION" + jdk: oraclejdk7 + - rvm: jruby-1.6.8 + gemfile: gemfiles/rails40.gemfile + env: JRUBY_OPTS="$JRUBY_OPTS" JAVA_OPTS="-Djruby.version=$JRUBY_VERSION" jdk: oraclejdk8 ## rails 4.1 won't run on --1.8 - rvm: jruby-1.7.16 @@ -191,6 +204,7 @@ matrix: gemfile: gemfiles/rails41.gemfile env: JRUBY_OPTS="--1.8 $JRUBY_OPTS" jdk: oraclejdk8 + ## rails 4.1 won't run on JRuby 1.6 - rvm: jruby-1.6.8 gemfile: gemfiles/rails41.gemfile env: JRUBY_OPTS="--1.8 $JRUBY_OPTS" @@ -203,6 +217,18 @@ matrix: gemfile: gemfiles/rails41.gemfile env: JRUBY_OPTS="--1.8 $JRUBY_OPTS" jdk: oraclejdk8 + - rvm: jruby-1.6.8 + gemfile: gemfiles/rails41.gemfile + env: JRUBY_OPTS="$JRUBY_OPTS" JAVA_OPTS="-Djruby.version=$JRUBY_VERSION" + jdk: openjdk6 + - rvm: jruby-1.6.8 + gemfile: gemfiles/rails41.gemfile + env: JRUBY_OPTS="$JRUBY_OPTS" JAVA_OPTS="-Djruby.version=$JRUBY_VERSION" + jdk: oraclejdk7 + - rvm: jruby-1.6.8 + gemfile: gemfiles/rails41.gemfile + env: JRUBY_OPTS="$JRUBY_OPTS" JAVA_OPTS="-Djruby.version=$JRUBY_VERSION" + jdk: oraclejdk8 ## rails 4.0 does not run on --1.8 (jruby-head) #- rvm: jruby-head # gemfile: gemfiles/rails40.gemfile From cdbf438670857491c0e7ee9a214037ce72cc44d9 Mon Sep 17 00:00:00 2001 From: kares Date: Sat, 10 Jan 2015 17:32:15 +0100 Subject: [PATCH 17/27] update to rack ~> 1.5.2 (for JRuby-Rack 1.1.x) --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 1d99c792..77beedbf 100644 --- a/Gemfile +++ b/Gemfile @@ -4,7 +4,7 @@ group :default do if rack_version = ENV['RACK_VERSION'] gem 'rack', rack_version else - gem 'rack', '~> 1.4.5' + gem 'rack', '~> 1.5.2' end end From b9f325a6c678cdb224792614d8dae64f517a98fd Mon Sep 17 00:00:00 2001 From: Christian Meier Date: Mon, 5 Jan 2015 17:00:34 +0100 Subject: [PATCH 18/27] introduce a new layout where the whole application + gems are packed under WEB-INF/classes when the app.root points to uri:classloader:// the rack-application can be packed one-to-one into WEB-INF/classes. similar for setting gem.path to uri:classloader:// allows to embed the gems in WEB-INF/classes. --- src/main/ruby/jruby/rack/app_layout.rb | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/main/ruby/jruby/rack/app_layout.rb b/src/main/ruby/jruby/rack/app_layout.rb index 3c4d2c69..11bedb73 100644 --- a/src/main/ruby/jruby/rack/app_layout.rb +++ b/src/main/ruby/jruby/rack/app_layout.rb @@ -40,6 +40,7 @@ def expand_path(path) def real_path(path) real_path = @rack_context.getRealPath(path) real_path.chomp!('/') if real_path + # just use the given path if there is no real path real_path end @@ -91,6 +92,31 @@ def expand_path(path) RailsWebInfLayout = WebInfLayout + class ClassPathLayout < WebInfLayout + + URI_CLASSLOADER = 'uri:classloader://' + + def real_path(path) + if path.start_with? URI_CLASSLOADER + path + else + super + end + end + + def app_uri + @app_uri ||= + @rack_context.getInitParameter('app.root') || + URI_CLASSLOADER + end + + def gem_uri + @gem_uri ||= + @rack_context.getInitParameter('gem.path') || + URI_CLASSLOADER + end + end + # @deprecated will be removed (with Merb support) class MerbWebInfLayout < WebInfLayout From f7569c7d860a565ca624102730cffb119fcba39b Mon Sep 17 00:00:00 2001 From: Christian Meier Date: Thu, 8 Jan 2015 12:09:47 +0100 Subject: [PATCH 19/27] search config.ru on context-classloader if not found otherwise --- .../rack/DefaultRackApplicationFactory.java | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/jruby/rack/DefaultRackApplicationFactory.java b/src/main/java/org/jruby/rack/DefaultRackApplicationFactory.java index b99faf26..6a8cea99 100644 --- a/src/main/java/org/jruby/rack/DefaultRackApplicationFactory.java +++ b/src/main/java/org/jruby/rack/DefaultRackApplicationFactory.java @@ -7,8 +7,10 @@ package org.jruby.rack; -import java.io.IOException; + import java.io.File; +import java.io.IOException; +import java.io.InputStream; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.net.URISyntaxException; @@ -531,15 +533,21 @@ private String resolveRackupScript() throws RackInitializationException { } } - if (rackup != null) { - rackupLocation = rackContext.getRealPath(rackup); - try { - rackup = IOHelpers.inputStreamToString(rackContext.getResourceAsStream(rackup)); + InputStream is = null; + try { + if (rackup != null) { + is = rackContext.getResourceAsStream(rackup); + rackupLocation = rackContext.getRealPath(rackup); } - catch (IOException e) { - rackContext.log(RackLogger.ERROR, "failed to read rackup from '"+ rackup + "' (" + e + ")"); - throw new RackInitializationException("failed to read rackup input", e); + else { + is = Thread.currentThread().getContextClassLoader().getResourceAsStream("config.ru"); + rackupLocation = "uri:classloader://config.ru"; } + rackup = IOHelpers.inputStreamToString(is); + } + catch (IOException e) { + rackContext.log(RackLogger.ERROR, "failed to read rackup from '"+ rackup + "' (" + e + ")"); + throw new RackInitializationException("failed to read rackup input", e); } } From 650d8304a6b0e07c0177a09eb4815212445144ce Mon Sep 17 00:00:00 2001 From: kares Date: Sun, 11 Jan 2015 13:37:09 +0100 Subject: [PATCH 20/27] context-loader rackup script resolution should work also when rackup.path configured closes #191 as merged --- .../rack/DefaultRackApplicationFactory.java | 65 +++++++++++++------ 1 file changed, 46 insertions(+), 19 deletions(-) diff --git a/src/main/java/org/jruby/rack/DefaultRackApplicationFactory.java b/src/main/java/org/jruby/rack/DefaultRackApplicationFactory.java index 6a8cea99..9858dea0 100644 --- a/src/main/java/org/jruby/rack/DefaultRackApplicationFactory.java +++ b/src/main/java/org/jruby/rack/DefaultRackApplicationFactory.java @@ -15,7 +15,6 @@ import java.lang.reflect.Method; import java.net.URISyntaxException; import java.net.URL; -import java.util.Iterator; import java.util.Map; import java.util.Set; @@ -501,13 +500,11 @@ private String findConfigRuPathInSubDirectories(final String path, int level) { if (level > 0) { level--; - for ( Iterator i = entries.iterator(); i.hasNext(); ) { - String subpath = i.next(); - if (subpath.endsWith("/")) { + for ( String subpath : entries ) { + final int len = subpath.length(); + if ( len > 0 && subpath.charAt(len - 1) == '/' ) { subpath = findConfigRuPathInSubDirectories(subpath, level); - if (subpath != null) { - return subpath; - } + if ( subpath != null ) return subpath; } } } @@ -515,9 +512,22 @@ private String findConfigRuPathInSubDirectories(final String path, int level) { return null; } - private String resolveRackupScript() throws RackInitializationException { - rackupLocation = ""; + private static String getContextLoaderScript(final String name, final boolean silent) + throws IOException { + try { // still try context-loader for resolving rackup : + final ClassLoader contextLoader = Thread.currentThread().getContextClassLoader(); + InputStream is = contextLoader.getResourceAsStream(name); + return IOHelpers.inputStreamToString(is); + } + catch (IOException e) { + if ( silent ) return null; throw e; + } + catch (RuntimeException e) { + if ( silent ) return null; throw e; + } + } + private String resolveRackupScript() throws RackInitializationException { String rackup = rackContext.getConfig().getRackup(); if (rackup == null) { rackup = rackContext.getConfig().getRackupPath(); @@ -533,23 +543,40 @@ private String resolveRackupScript() throws RackInitializationException { } } - InputStream is = null; - try { - if (rackup != null) { + if (rackup != null) { + InputStream is; + try { is = rackContext.getResourceAsStream(rackup); rackupLocation = rackContext.getRealPath(rackup); + return this.rackupScript = IOHelpers.inputStreamToString(is); } - else { - is = Thread.currentThread().getContextClassLoader().getResourceAsStream("config.ru"); - rackupLocation = "uri:classloader://config.ru"; + catch (IOException e) { + try { // last - try context-loader for resolving rackup : + if ( (rackup = getContextLoaderScript(rackup, true)) != null ) { + return this.rackupScript = rackup; + } + } + catch (IOException ex) { /* won't happen */ } + + rackContext.log(RackLogger.ERROR, "failed to read rackup from '"+ rackup + "' (" + e + ")"); + throw new RackInitializationException("failed to read rackup input", e); } - rackup = IOHelpers.inputStreamToString(is); } - catch (IOException e) { - rackContext.log(RackLogger.ERROR, "failed to read rackup from '"+ rackup + "' (" + e + ")"); - throw new RackInitializationException("failed to read rackup input", e); + else { + rackup = "config.ru"; + try { + rackup = getContextLoaderScript(rackup, false); + rackupLocation = "uri:classloader://config.ru"; + } + catch (IOException e) { + rackContext.log(RackLogger.ERROR, "failed to read rackup from '"+ rackup + "' (" + e + ")"); + throw new RackInitializationException("failed to read rackup input", e); + } } } + else { + rackupLocation = ""; + } return this.rackupScript = rackup; } From 40a4985473336d42ea810c0cf1b81845f48fea0f Mon Sep 17 00:00:00 2001 From: kares Date: Sun, 11 Jan 2015 13:39:21 +0100 Subject: [PATCH 21/27] missed Gemfile.lock for rack ~> 1.5.2 --- Gemfile.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 3f55df99..1ba3769b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -6,7 +6,7 @@ GEM rake diff-lcs (1.2.5) jruby-openssl (0.9.6-java) - rack (1.4.5) + rack (1.5.2) rake (10.3.2) rspec (2.14.1) rspec-core (~> 2.14.0) @@ -23,6 +23,6 @@ PLATFORMS DEPENDENCIES appraisal jruby-openssl - rack (~> 1.4.5) + rack (~> 1.5.2) rake (~> 10.3.1) rspec (~> 2.14.1) From c0b925ecd913d8d31f78468361df13b011d9fd6c Mon Sep 17 00:00:00 2001 From: kares Date: Sun, 11 Jan 2015 15:55:52 +0100 Subject: [PATCH 22/27] back-port Rack::ShowStatus to be used with out ErrorApp (contains XSS fix see #190) more details at https://github.com/rack/rack/commit/479fe8fecad0b33b88e6a9de01 --- .../ruby/jruby/rack/error_app/show_status.rb | 113 ++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 src/main/ruby/jruby/rack/error_app/show_status.rb diff --git a/src/main/ruby/jruby/rack/error_app/show_status.rb b/src/main/ruby/jruby/rack/error_app/show_status.rb new file mode 100644 index 00000000..d80ce2c1 --- /dev/null +++ b/src/main/ruby/jruby/rack/error_app/show_status.rb @@ -0,0 +1,113 @@ +require 'erb' +require 'rack/request' +require 'rack/utils' + +class JRuby::Rack::ErrorApp + # Rack::ShowStatus catches all empty responses and replaces them + # with a site explaining the error. + # + # Additional details can be put into rack.showstatus.detail + # and will be shown as HTML. If such details exist, the error page + # is always rendered, even if the reply was not empty. + + class ShowStatus + def initialize(app) + @app = app + @template = ERB.new(TEMPLATE) + end + + def call(env) + status, headers, body = @app.call(env) + headers = Utils::HeaderHash.new(headers) + empty = headers[CONTENT_LENGTH].to_i <= 0 + + # client or server error, or explicit message + if (status.to_i >= 400 && empty) || env["rack.showstatus.detail"] + # This double assignment is to prevent an "unused variable" warning on + # Ruby 1.9.3. Yes, it is dumb, but I don't like Ruby yelling at me. + req = req = Rack::Request.new(env) + + message = Rack::Utils::HTTP_STATUS_CODES[status.to_i] || status.to_s + + # This double assignment is to prevent an "unused variable" warning on + # Ruby 1.9.3. Yes, it is dumb, but I don't like Ruby yelling at me. + detail = detail = env["rack.showstatus.detail"] || message + + body = @template.result(binding) + size = Rack::Utils.bytesize(body) + [status, headers.merge(CONTENT_TYPE => "text/html", CONTENT_LENGTH => size.to_s), [body]] + else + [status, headers, body] + end + end + + def h(obj) # :nodoc: + case obj + when String + Utils.escape_html(obj) + else + Utils.escape_html(obj.inspect) + end + end + + # :stopdoc: + +# adapted from Django +# Copyright (c) 2005, the Lawrence Journal-World +# Used under the modified BSD license: +# http://www.xfree86.org/3.3.6/COPYRIGHT2.html#5 +TEMPLATE = <<'HTML' + + + + + <%=h message %> at <%=h req.script_name + req.path_info %> + + + + +
+

<%=h message %> (<%= status.to_i %>)

+ + + + + + + + + +
Request Method:<%=h req.request_method %>
Request URL:<%=h req.url %>
+
+
+

<%=h detail %>

+
+ +
+

+ You're seeing this error because you use Rack::ShowStatus. +

+
+ + +HTML + + # :startdoc: + end +end From dae7ca741093734a588725ba061f8ebdcd4f2064 Mon Sep 17 00:00:00 2001 From: kares Date: Sun, 11 Jan 2015 16:53:25 +0100 Subject: [PATCH 23/27] make back-ported ShowStatus compatible and use it instead of Rack::ShowStatus see #190 for details --- .../rack/DefaultRackApplicationFactory.java | 2 +- src/main/ruby/jruby/rack/error_app.rb | 2 + .../ruby/jruby/rack/error_app/show_status.rb | 38 ++++++++----------- src/spec/ruby/rack/application_spec.rb | 4 +- 4 files changed, 21 insertions(+), 25 deletions(-) diff --git a/src/main/java/org/jruby/rack/DefaultRackApplicationFactory.java b/src/main/java/org/jruby/rack/DefaultRackApplicationFactory.java index 9858dea0..88d7fbb7 100644 --- a/src/main/java/org/jruby/rack/DefaultRackApplicationFactory.java +++ b/src/main/java/org/jruby/rack/DefaultRackApplicationFactory.java @@ -189,7 +189,7 @@ public IRubyObject createErrorApplicationObject(final Ruby runtime) { } if (errorApp == null) { errorApp = "require 'jruby/rack/error_app' \n" + - "use Rack::ShowStatus \n" + + "use JRuby::Rack::ErrorApp::ShowStatus \n" + "run JRuby::Rack::ErrorApp.new"; } runtime.evalScriptlet("load 'jruby/rack/boot/rack.rb'"); diff --git a/src/main/ruby/jruby/rack/error_app.rb b/src/main/ruby/jruby/rack/error_app.rb index 3e7d27d3..8763a126 100644 --- a/src/main/ruby/jruby/rack/error_app.rb +++ b/src/main/ruby/jruby/rack/error_app.rb @@ -9,6 +9,8 @@ module JRuby module Rack class ErrorApp + autoload :ShowStatus, 'jruby/rack/error_app/show_status' + EXCEPTION = org.jruby.rack.RackEnvironment::EXCEPTION DEFAULT_RESPONSE_CODE = 500 diff --git a/src/main/ruby/jruby/rack/error_app/show_status.rb b/src/main/ruby/jruby/rack/error_app/show_status.rb index d80ce2c1..835f3d25 100644 --- a/src/main/ruby/jruby/rack/error_app/show_status.rb +++ b/src/main/ruby/jruby/rack/error_app/show_status.rb @@ -3,14 +3,12 @@ require 'rack/utils' class JRuby::Rack::ErrorApp - # Rack::ShowStatus catches all empty responses and replaces them - # with a site explaining the error. - # - # Additional details can be put into rack.showstatus.detail - # and will be shown as HTML. If such details exist, the error page - # is always rendered, even if the reply was not empty. + # catches empty responses and replaces them with a site explaining the error. + # + # @note kindly adapted from on Rack::ShowStatus class ShowStatus + def initialize(app) @app = app @template = ERB.new(TEMPLATE) @@ -18,35 +16,31 @@ def initialize(app) def call(env) status, headers, body = @app.call(env) - headers = Utils::HeaderHash.new(headers) - empty = headers[CONTENT_LENGTH].to_i <= 0 + headers = ::Rack::Utils::HeaderHash.new(headers) + empty = headers['Content-Length'].to_i <= 0 # client or server error, or explicit message if (status.to_i >= 400 && empty) || env["rack.showstatus.detail"] - # This double assignment is to prevent an "unused variable" warning on - # Ruby 1.9.3. Yes, it is dumb, but I don't like Ruby yelling at me. - req = req = Rack::Request.new(env) - - message = Rack::Utils::HTTP_STATUS_CODES[status.to_i] || status.to_s - - # This double assignment is to prevent an "unused variable" warning on - # Ruby 1.9.3. Yes, it is dumb, but I don't like Ruby yelling at me. + # required erb template variables (captured with binding) : + req = req = ::Rack::Request.new(env) + message = ::Rack::Utils::HTTP_STATUS_CODES[status.to_i] || status.to_s detail = detail = env["rack.showstatus.detail"] || message body = @template.result(binding) - size = Rack::Utils.bytesize(body) - [status, headers.merge(CONTENT_TYPE => "text/html", CONTENT_LENGTH => size.to_s), [body]] + size = ::Rack::Utils.bytesize(body) + [status, headers.merge('Content-Type' => "text/html", 'Content-Length' => size.to_s), [body]] else [status, headers, body] end end - def h(obj) # :nodoc: + # @private + def h(obj) case obj when String - Utils.escape_html(obj) + ::Rack::Utils.escape_html(obj) else - Utils.escape_html(obj.inspect) + ::Rack::Utils.escape_html(obj.inspect) end end @@ -101,7 +95,7 @@ def h(obj) # :nodoc:

- You're seeing this error because you use Rack::ShowStatus. + You're seeing this error because you use JRuby::Rack::ErrorApp::ShowStatus.

diff --git a/src/spec/ruby/rack/application_spec.rb b/src/spec/ruby/rack/application_spec.rb index 8c816c19..66234f0c 100644 --- a/src/spec/ruby/rack/application_spec.rb +++ b/src/spec/ruby/rack/application_spec.rb @@ -269,8 +269,8 @@ def newRuntime() # use the current runtime instead of creating new #expect( rack_app ).to be_a Rack::Handler::Servlet expect( rack_app.class.name ).to eql 'Rack::Handler::Servlet' app = rack_app.instance_variable_get('@app') - expect( app ).to be_a Rack::ShowStatus - #expect( app.class.name ).to eql 'Rack::ShowStatus' + expect( app ).to be_a JRuby::Rack::ErrorApp::ShowStatus + #expect( app.class.name ).to eql 'JRuby::Rack::ErrorApp::ShowStatus' error_app = app.instance_variable_get('@app') expect( error_app ).to be_a JRuby::Rack::ErrorApp #expect( error_app.class.name ).to eql 'JRuby::Rack::ErrorApp' From 914416dce5fb239c11c9e698be5cfc33e50bf903 Mon Sep 17 00:00:00 2001 From: kares Date: Sun, 11 Jan 2015 17:42:48 +0100 Subject: [PATCH 24/27] setup and integration spec with a Rails 4.1 stub --- .travis.yml | 2 +- gemfiles/rails40.gemfile.lock | 63 +++++++------- gemfiles/rails41.gemfile.lock | 79 +++++++++--------- src/spec/ruby/jruby/rack/integration_spec.rb | 68 ++++++++++++--- src/spec/stub/rails41/.gitignore | 2 + src/spec/stub/rails41/Rakefile | 6 ++ src/spec/stub/rails41/app/assets/images/.keep | 0 .../app/assets/javascripts/application.js | 16 ++++ .../app/assets/stylesheets/application.css | 15 ++++ .../app/controllers/application_controller.rb | 5 ++ .../rails41/app/controllers/concerns/.keep | 0 .../rails41/app/helpers/application_helper.rb | 2 + src/spec/stub/rails41/app/mailers/.keep | 0 src/spec/stub/rails41/app/models/.keep | 0 .../stub/rails41/app/models/concerns/.keep | 0 .../app/views/layouts/application.html.erb | 14 ++++ src/spec/stub/rails41/config/application.rb | 26 ++++++ src/spec/stub/rails41/config/boot.rb | 4 + src/spec/stub/rails41/config/environment.rb | 5 ++ .../config/environments/development.rb | 37 +++++++++ .../rails41/config/environments/production.rb | 82 +++++++++++++++++++ .../rails41/config/initializers/assets.rb | 8 ++ .../initializers/backtrace_silencers.rb | 7 ++ .../config/initializers/cookies_serializer.rb | 3 + .../initializers/filter_parameter_logging.rb | 4 + .../config/initializers/inflections.rb | 16 ++++ .../rails41/config/initializers/mime_types.rb | 4 + .../config/initializers/session_store.rb | 3 + .../config/initializers/wrap_parameters.rb | 14 ++++ src/spec/stub/rails41/config/locales/en.yml | 23 ++++++ src/spec/stub/rails41/config/routes.rb | 56 +++++++++++++ src/spec/stub/rails41/config/secrets.yml | 23 ++++++ src/spec/stub/rails41/db/seeds.rb | 7 ++ src/spec/stub/rails41/lib/assets/.keep | 0 src/spec/stub/rails41/lib/tasks/.keep | 0 src/spec/stub/rails41/public/404.html | 67 +++++++++++++++ src/spec/stub/rails41/public/422.html | 67 +++++++++++++++ src/spec/stub/rails41/public/500.html | 66 +++++++++++++++ src/spec/stub/rails41/public/robots.txt | 5 ++ .../rails41/vendor/assets/javascripts/.keep | 0 .../rails41/vendor/assets/stylesheets/.keep | 0 41 files changed, 712 insertions(+), 87 deletions(-) create mode 100644 src/spec/stub/rails41/.gitignore create mode 100644 src/spec/stub/rails41/Rakefile create mode 100644 src/spec/stub/rails41/app/assets/images/.keep create mode 100644 src/spec/stub/rails41/app/assets/javascripts/application.js create mode 100644 src/spec/stub/rails41/app/assets/stylesheets/application.css create mode 100644 src/spec/stub/rails41/app/controllers/application_controller.rb create mode 100644 src/spec/stub/rails41/app/controllers/concerns/.keep create mode 100644 src/spec/stub/rails41/app/helpers/application_helper.rb create mode 100644 src/spec/stub/rails41/app/mailers/.keep create mode 100644 src/spec/stub/rails41/app/models/.keep create mode 100644 src/spec/stub/rails41/app/models/concerns/.keep create mode 100644 src/spec/stub/rails41/app/views/layouts/application.html.erb create mode 100644 src/spec/stub/rails41/config/application.rb create mode 100644 src/spec/stub/rails41/config/boot.rb create mode 100644 src/spec/stub/rails41/config/environment.rb create mode 100644 src/spec/stub/rails41/config/environments/development.rb create mode 100644 src/spec/stub/rails41/config/environments/production.rb create mode 100644 src/spec/stub/rails41/config/initializers/assets.rb create mode 100644 src/spec/stub/rails41/config/initializers/backtrace_silencers.rb create mode 100644 src/spec/stub/rails41/config/initializers/cookies_serializer.rb create mode 100644 src/spec/stub/rails41/config/initializers/filter_parameter_logging.rb create mode 100644 src/spec/stub/rails41/config/initializers/inflections.rb create mode 100644 src/spec/stub/rails41/config/initializers/mime_types.rb create mode 100644 src/spec/stub/rails41/config/initializers/session_store.rb create mode 100644 src/spec/stub/rails41/config/initializers/wrap_parameters.rb create mode 100644 src/spec/stub/rails41/config/locales/en.yml create mode 100644 src/spec/stub/rails41/config/routes.rb create mode 100644 src/spec/stub/rails41/config/secrets.yml create mode 100644 src/spec/stub/rails41/db/seeds.rb create mode 100644 src/spec/stub/rails41/lib/assets/.keep create mode 100644 src/spec/stub/rails41/lib/tasks/.keep create mode 100644 src/spec/stub/rails41/public/404.html create mode 100644 src/spec/stub/rails41/public/422.html create mode 100644 src/spec/stub/rails41/public/500.html create mode 100644 src/spec/stub/rails41/public/robots.txt create mode 100644 src/spec/stub/rails41/vendor/assets/javascripts/.keep create mode 100644 src/spec/stub/rails41/vendor/assets/stylesheets/.keep diff --git a/.travis.yml b/.travis.yml index 1f07ff7d..8d72ce81 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,7 +22,7 @@ gemfile: - gemfiles/rails31.gemfile - gemfiles/rails32.gemfile - gemfiles/rails40.gemfile - #- gemfiles/rails41.gemfile + - gemfiles/rails41.gemfile env: - JRUBY_OPTS="--1.8 $JRUBY_OPTS" - JRUBY_OPTS="$JRUBY_OPTS" JAVA_OPTS="-Djruby.version=$JRUBY_VERSION" # for mvn's jruby plugins diff --git a/gemfiles/rails40.gemfile.lock b/gemfiles/rails40.gemfile.lock index 7e6da97d..b15a4cf8 100644 --- a/gemfiles/rails40.gemfile.lock +++ b/gemfiles/rails40.gemfile.lock @@ -1,25 +1,25 @@ GEM remote: https://rubygems.org/ specs: - actionmailer (4.0.8) - actionpack (= 4.0.8) - mail (~> 2.5.4) - actionpack (4.0.8) - activesupport (= 4.0.8) + actionmailer (4.0.13) + actionpack (= 4.0.13) + mail (~> 2.5, >= 2.5.4) + actionpack (4.0.13) + activesupport (= 4.0.13) builder (~> 3.1.0) erubis (~> 2.7.0) rack (~> 1.5.2) rack-test (~> 0.6.2) - activemodel (4.0.8) - activesupport (= 4.0.8) + activemodel (4.0.13) + activesupport (= 4.0.13) builder (~> 3.1.0) - activerecord (4.0.8) - activemodel (= 4.0.8) + activerecord (4.0.13) + activemodel (= 4.0.13) activerecord-deprecated_finders (~> 1.0.2) - activesupport (= 4.0.8) + activesupport (= 4.0.13) arel (~> 4.0.0) activerecord-deprecated_finders (1.0.3) - activesupport (4.0.8) + activesupport (4.0.13) i18n (~> 0.6, >= 0.6.9) minitest (~> 4.2) multi_json (~> 1.3) @@ -30,28 +30,26 @@ GEM diff-lcs (1.2.5) erubis (2.7.0) hike (1.2.3) - i18n (0.6.11) - mail (2.5.4) - mime-types (~> 1.16) - treetop (~> 1.4.8) - mime-types (1.25.1) + i18n (0.7.0) + mail (2.6.3) + mime-types (>= 1.16, < 3) + mime-types (2.4.3) minitest (4.7.5) multi_json (1.10.1) - polyglot (0.3.5) rack (1.5.2) - rack-test (0.6.2) + rack-test (0.6.3) rack (>= 1.0) - rails (4.0.8) - actionmailer (= 4.0.8) - actionpack (= 4.0.8) - activerecord (= 4.0.8) - activesupport (= 4.0.8) + rails (4.0.13) + actionmailer (= 4.0.13) + actionpack (= 4.0.13) + activerecord (= 4.0.13) + activesupport (= 4.0.13) bundler (>= 1.3.0, < 2.0) - railties (= 4.0.8) + railties (= 4.0.13) sprockets-rails (~> 2.0) - railties (4.0.8) - actionpack (= 4.0.8) - activesupport (= 4.0.8) + railties (4.0.13) + actionpack (= 4.0.13) + activesupport (= 4.0.13) rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) rake (10.3.2) @@ -63,22 +61,19 @@ GEM rspec-expectations (2.14.5) diff-lcs (>= 1.1.3, < 2.0) rspec-mocks (2.14.6) - sprockets (2.12.1) + sprockets (2.12.3) hike (~> 1.2) multi_json (~> 1.0) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) - sprockets-rails (2.1.3) + sprockets-rails (2.2.2) actionpack (>= 3.0) activesupport (>= 3.0) - sprockets (~> 2.8) + sprockets (>= 2.8, < 4.0) thor (0.19.1) thread_safe (0.3.4-java) tilt (1.4.1) - treetop (1.4.15) - polyglot - polyglot (>= 0.3.1) - tzinfo (0.3.40) + tzinfo (0.3.42) PLATFORMS java diff --git a/gemfiles/rails41.gemfile.lock b/gemfiles/rails41.gemfile.lock index 961d1133..51e6ae5e 100644 --- a/gemfiles/rails41.gemfile.lock +++ b/gemfiles/rails41.gemfile.lock @@ -1,27 +1,27 @@ GEM remote: https://rubygems.org/ specs: - actionmailer (4.1.4) - actionpack (= 4.1.4) - actionview (= 4.1.4) - mail (~> 2.5.4) - actionpack (4.1.4) - actionview (= 4.1.4) - activesupport (= 4.1.4) + actionmailer (4.1.9) + actionpack (= 4.1.9) + actionview (= 4.1.9) + mail (~> 2.5, >= 2.5.4) + actionpack (4.1.9) + actionview (= 4.1.9) + activesupport (= 4.1.9) rack (~> 1.5.2) rack-test (~> 0.6.2) - actionview (4.1.4) - activesupport (= 4.1.4) + actionview (4.1.9) + activesupport (= 4.1.9) builder (~> 3.1) erubis (~> 2.7.0) - activemodel (4.1.4) - activesupport (= 4.1.4) + activemodel (4.1.9) + activesupport (= 4.1.9) builder (~> 3.1) - activerecord (4.1.4) - activemodel (= 4.1.4) - activesupport (= 4.1.4) + activerecord (4.1.9) + activemodel (= 4.1.9) + activesupport (= 4.1.9) arel (~> 5.0.0) - activesupport (4.1.4) + activesupport (4.1.9) i18n (~> 0.6, >= 0.6.9) json (~> 1.7, >= 1.7.7) minitest (~> 5.1) @@ -32,31 +32,29 @@ GEM diff-lcs (1.2.5) erubis (2.7.0) hike (1.2.3) - i18n (0.6.11) - json (1.8.1-java) - mail (2.5.4) - mime-types (~> 1.16) - treetop (~> 1.4.8) - mime-types (1.25.1) - minitest (5.4.0) + i18n (0.7.0) + json (1.8.2-java) + mail (2.6.3) + mime-types (>= 1.16, < 3) + mime-types (2.4.3) + minitest (5.5.1) multi_json (1.10.1) - polyglot (0.3.5) rack (1.5.2) - rack-test (0.6.2) + rack-test (0.6.3) rack (>= 1.0) - rails (4.1.4) - actionmailer (= 4.1.4) - actionpack (= 4.1.4) - actionview (= 4.1.4) - activemodel (= 4.1.4) - activerecord (= 4.1.4) - activesupport (= 4.1.4) + rails (4.1.9) + actionmailer (= 4.1.9) + actionpack (= 4.1.9) + actionview (= 4.1.9) + activemodel (= 4.1.9) + activerecord (= 4.1.9) + activesupport (= 4.1.9) bundler (>= 1.3.0, < 2.0) - railties (= 4.1.4) + railties (= 4.1.9) sprockets-rails (~> 2.0) - railties (4.1.4) - actionpack (= 4.1.4) - activesupport (= 4.1.4) + railties (4.1.9) + actionpack (= 4.1.9) + activesupport (= 4.1.9) rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) rake (10.3.2) @@ -68,22 +66,19 @@ GEM rspec-expectations (2.14.5) diff-lcs (>= 1.1.3, < 2.0) rspec-mocks (2.14.6) - sprockets (2.12.1) + sprockets (2.12.3) hike (~> 1.2) multi_json (~> 1.0) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) - sprockets-rails (2.1.3) + sprockets-rails (2.2.2) actionpack (>= 3.0) activesupport (>= 3.0) - sprockets (~> 2.8) + sprockets (>= 2.8, < 4.0) thor (0.19.1) thread_safe (0.3.4-java) tilt (1.4.1) - treetop (1.4.15) - polyglot - polyglot (>= 0.3.1) - tzinfo (1.2.1) + tzinfo (1.2.2) thread_safe (~> 0.1) PLATFORMS diff --git a/src/spec/ruby/jruby/rack/integration_spec.rb b/src/spec/ruby/jruby/rack/integration_spec.rb index 99591502..d04a61a4 100644 --- a/src/spec/ruby/jruby/rack/integration_spec.rb +++ b/src/spec/ruby/jruby/rack/integration_spec.rb @@ -1,7 +1,5 @@ require File.expand_path('spec_helper', File.dirname(__FILE__) + '/../..') -require 'fileutils' -require 'jruby' java_import org.jruby.rack.RackContext java_import org.jruby.rack.servlet.ServletRackContext @@ -15,6 +13,8 @@ describe "integration" do + before(:all) { require 'fileutils' } + #after(:all) { JRuby::Rack.context = nil } describe 'rack (lambda)' do @@ -90,12 +90,7 @@ shared_examples_for 'a rails app', :shared => true do - let(:servlet_context) do - servlet_context = org.jruby.rack.mock.MockServletContext.new base_path - servlet_context.logger = raise_logger - set_compat_version servlet_context - servlet_context - end + let(:servlet_context) { new_servlet_context(base_path) } it "initializes (pooling by default)" do listener = org.jruby.rack.rails.RailsServletContextListener.new @@ -318,6 +313,55 @@ end + describe 'rails 4.1', :lib => :rails41 do + + before(:all) do name = :rails41 # copy_gemfile : + FileUtils.cp File.join(GEMFILES_DIR, "#{name}.gemfile"), File.join(STUB_DIR, "#{name}/Gemfile") + FileUtils.cp File.join(GEMFILES_DIR, "#{name}.gemfile.lock"), File.join(STUB_DIR, "#{name}/Gemfile.lock") + Dir.chdir File.join(STUB_DIR, name.to_s) + end + + def prepare_servlet_context(servlet_context) + servlet_context.addInitParameter('rails.root', "#{STUB_DIR}/rails41") + servlet_context.addInitParameter('jruby.rack.layout_class', 'FileSystemLayout') + end + + def base_path; "file://#{STUB_DIR}/rails41" end + # let(:base_path) { "file://#{STUB_DIR}/rails41" } + + it_should_behave_like 'a rails app' + + context "initialized" do + + before(:all) { initialize_rails 'production', base_path } + after(:all) { restore_rails } + + it "loaded rack ~> 1.5" do + @runtime = @rack_factory.getApplication.getRuntime + should_eval_as_not_nil "defined?(Rack.release)" + should_eval_as_eql_to "Rack.release.to_s[0, 3]", '1.5' + end + + it "booted with a servlet logger" do + @runtime = @rack_factory.getApplication.getRuntime + should_eval_as_not_nil "defined?(Rails)" + should_eval_as_not_nil "Rails.logger" + # NOTE: TaggedLogging is a module that extends the instance now : + should_eval_as_eql_to "Rails.logger.is_a? ActiveSupport::TaggedLogging", true + should_eval_as_eql_to "Rails.logger.instance_variable_get(:'@logdev').dev.class.name", + 'JRuby::Rack::ServletLog' + should_eval_as_eql_to "Rails.logger.level", Logger::INFO + end + + it "sets up public_path (as for a war)" do + @runtime = @rack_factory.getApplication.getRuntime + should_eval_as_eql_to "Rails.public_path.to_s", "#{STUB_DIR}/rails41/public" + end + + end + + end + describe 'rails 2.3', :lib => :rails23 do before(:all) do @@ -411,11 +455,15 @@ def restore_rails def new_servlet_context(base_path = nil) servlet_context = org.jruby.rack.mock.MockServletContext.new base_path servlet_context.logger = raise_logger - set_compat_version servlet_context + prepare_servlet_context servlet_context servlet_context end - def set_compat_version(servlet_context = @servlet_context) + def prepare_servlet_context(servlet_context) + set_compat_version servlet_context + end + + def set_compat_version(servlet_context = @servlet_context); require 'jruby' compat_version = JRuby.runtime.getInstanceConfig.getCompatVersion # RUBY1_9 servlet_context.addInitParameter("jruby.compat.version", compat_version.to_s) end diff --git a/src/spec/stub/rails41/.gitignore b/src/spec/stub/rails41/.gitignore new file mode 100644 index 00000000..65e0d93c --- /dev/null +++ b/src/spec/stub/rails41/.gitignore @@ -0,0 +1,2 @@ +Gemfile +Gemfile.lock diff --git a/src/spec/stub/rails41/Rakefile b/src/spec/stub/rails41/Rakefile new file mode 100644 index 00000000..ba6b733d --- /dev/null +++ b/src/spec/stub/rails41/Rakefile @@ -0,0 +1,6 @@ +# Add your own tasks in files placed in lib/tasks ending in .rake, +# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. + +require File.expand_path('../config/application', __FILE__) + +Rails.application.load_tasks diff --git a/src/spec/stub/rails41/app/assets/images/.keep b/src/spec/stub/rails41/app/assets/images/.keep new file mode 100644 index 00000000..e69de29b diff --git a/src/spec/stub/rails41/app/assets/javascripts/application.js b/src/spec/stub/rails41/app/assets/javascripts/application.js new file mode 100644 index 00000000..d6925fa4 --- /dev/null +++ b/src/spec/stub/rails41/app/assets/javascripts/application.js @@ -0,0 +1,16 @@ +// This is a manifest file that'll be compiled into application.js, which will include all the files +// listed below. +// +// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, +// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path. +// +// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the +// compiled file. +// +// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details +// about supported directives. +// +//= require jquery +//= require jquery_ujs +//= require turbolinks +//= require_tree . diff --git a/src/spec/stub/rails41/app/assets/stylesheets/application.css b/src/spec/stub/rails41/app/assets/stylesheets/application.css new file mode 100644 index 00000000..a443db34 --- /dev/null +++ b/src/spec/stub/rails41/app/assets/stylesheets/application.css @@ -0,0 +1,15 @@ +/* + * This is a manifest file that'll be compiled into application.css, which will include all the files + * listed below. + * + * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, + * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path. + * + * You're free to add application-wide styles to this file and they'll appear at the bottom of the + * compiled file so the styles you add here take precedence over styles defined in any styles + * defined in the other CSS/SCSS files in this directory. It is generally better to create a new + * file per style scope. + * + *= require_tree . + *= require_self + */ diff --git a/src/spec/stub/rails41/app/controllers/application_controller.rb b/src/spec/stub/rails41/app/controllers/application_controller.rb new file mode 100644 index 00000000..d83690e1 --- /dev/null +++ b/src/spec/stub/rails41/app/controllers/application_controller.rb @@ -0,0 +1,5 @@ +class ApplicationController < ActionController::Base + # Prevent CSRF attacks by raising an exception. + # For APIs, you may want to use :null_session instead. + protect_from_forgery with: :exception +end diff --git a/src/spec/stub/rails41/app/controllers/concerns/.keep b/src/spec/stub/rails41/app/controllers/concerns/.keep new file mode 100644 index 00000000..e69de29b diff --git a/src/spec/stub/rails41/app/helpers/application_helper.rb b/src/spec/stub/rails41/app/helpers/application_helper.rb new file mode 100644 index 00000000..de6be794 --- /dev/null +++ b/src/spec/stub/rails41/app/helpers/application_helper.rb @@ -0,0 +1,2 @@ +module ApplicationHelper +end diff --git a/src/spec/stub/rails41/app/mailers/.keep b/src/spec/stub/rails41/app/mailers/.keep new file mode 100644 index 00000000..e69de29b diff --git a/src/spec/stub/rails41/app/models/.keep b/src/spec/stub/rails41/app/models/.keep new file mode 100644 index 00000000..e69de29b diff --git a/src/spec/stub/rails41/app/models/concerns/.keep b/src/spec/stub/rails41/app/models/concerns/.keep new file mode 100644 index 00000000..e69de29b diff --git a/src/spec/stub/rails41/app/views/layouts/application.html.erb b/src/spec/stub/rails41/app/views/layouts/application.html.erb new file mode 100644 index 00000000..191ac3c1 --- /dev/null +++ b/src/spec/stub/rails41/app/views/layouts/application.html.erb @@ -0,0 +1,14 @@ + + + + Rails41 + <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %> + <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %> + <%= csrf_meta_tags %> + + + +<%= yield %> + + + diff --git a/src/spec/stub/rails41/config/application.rb b/src/spec/stub/rails41/config/application.rb new file mode 100644 index 00000000..73c653f4 --- /dev/null +++ b/src/spec/stub/rails41/config/application.rb @@ -0,0 +1,26 @@ +require File.expand_path('../boot', __FILE__) + +#require 'rails/all' +require 'action_controller/railtie' +require 'action_mailer/railtie' +require 'sprockets/railtie' + +# Require the gems listed in Gemfile, including any gems +# you've limited to :test, :development, or :production. +Bundler.require(*Rails.groups) + +module Rails41 + class Application < Rails::Application + # Settings in config/environments/* take precedence over those specified here. + # Application configuration should go into files in config/initializers + # -- all .rb files in that directory are automatically loaded. + + # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. + # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. + # config.time_zone = 'Central Time (US & Canada)' + + # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. + # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] + # config.i18n.default_locale = :de + end +end diff --git a/src/spec/stub/rails41/config/boot.rb b/src/spec/stub/rails41/config/boot.rb new file mode 100644 index 00000000..20fa9d80 --- /dev/null +++ b/src/spec/stub/rails41/config/boot.rb @@ -0,0 +1,4 @@ +# Set up gems listed in the Gemfile. +ENV['BUNDLE_GEMFILE'] = File.expand_path('../../Gemfile', __FILE__) + +require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE']) diff --git a/src/spec/stub/rails41/config/environment.rb b/src/spec/stub/rails41/config/environment.rb new file mode 100644 index 00000000..052dd73a --- /dev/null +++ b/src/spec/stub/rails41/config/environment.rb @@ -0,0 +1,5 @@ +# Load the Rails application. +require File.expand_path('../application', __FILE__) + +# Initialize the Rails application. +Rails.application.initialize! \ No newline at end of file diff --git a/src/spec/stub/rails41/config/environments/development.rb b/src/spec/stub/rails41/config/environments/development.rb new file mode 100644 index 00000000..c8203c1a --- /dev/null +++ b/src/spec/stub/rails41/config/environments/development.rb @@ -0,0 +1,37 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # In the development environment your application's code is reloaded on + # every request. This slows down response time but is perfect for development + # since you don't have to restart the web server when you make code changes. + config.cache_classes = false + + # Do not eager load code on boot. + config.eager_load = false + + # Show full error reports and disable caching. + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + + # Don't care if the mailer can't send. + config.action_mailer.raise_delivery_errors = false + + # Print deprecation notices to the Rails logger. + config.active_support.deprecation = :log + + # Raise an error on page load if there are pending migrations. + config.active_record.migration_error = :page_load if config.respond_to?(:active_record) + + # Debug mode disables concatenation and preprocessing of assets. + # This option may cause significant delays in view rendering with a large + # number of complex assets. + config.assets.debug = true + + # Adds additional error checking when serving assets at runtime. + # Checks for improperly declared sprockets dependencies. + # Raises helpful error messages. + config.assets.raise_runtime_errors = true + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true +end diff --git a/src/spec/stub/rails41/config/environments/production.rb b/src/spec/stub/rails41/config/environments/production.rb new file mode 100644 index 00000000..b6f70024 --- /dev/null +++ b/src/spec/stub/rails41/config/environments/production.rb @@ -0,0 +1,82 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # Code is not reloaded between requests. + config.cache_classes = true + + # Eager load code on boot. This eager loads most of Rails and + # your application in memory, allowing both threaded web servers + # and those relying on copy on write to perform better. + # Rake tasks automatically ignore this option for performance. + config.eager_load = true + + # Full error reports are disabled and caching is turned on. + config.consider_all_requests_local = false + config.action_controller.perform_caching = true + + # Enable Rack::Cache to put a simple HTTP cache in front of your application + # Add `rack-cache` to your Gemfile before enabling this. + # For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid. + # config.action_dispatch.rack_cache = true + + # Disable Rails's static asset server (Apache or nginx will already do this). + config.serve_static_assets = false + + # Compress JavaScripts and CSS. + config.assets.js_compressor = :uglifier + # config.assets.css_compressor = :sass + + # Do not fallback to assets pipeline if a precompiled asset is missed. + config.assets.compile = false + + # Generate digests for assets URLs. + config.assets.digest = true + + # `config.assets.precompile` has moved to config/initializers/assets.rb + + # Specifies the header that your server uses for sending files. + # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true + + # Set to :debug to see everything in the log. + #config.log_level = :info + + # Prepend all log lines with the following tags. + # config.log_tags = [ :subdomain, :uuid ] + + # Use a different logger for distributed setups. + # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) + + # Use a different cache store in production. + # config.cache_store = :mem_cache_store + + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.action_controller.asset_host = "http://assets.example.com" + + # Precompile additional assets. + # application.js, application.css, and all non-JS/CSS in app/assets folder are already added. + # config.assets.precompile += %w( search.js ) + + # Ignore bad email addresses and do not raise email delivery errors. + # Set this to true and configure the email server for immediate delivery to raise delivery errors. + # config.action_mailer.raise_delivery_errors = false + + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation cannot be found). + config.i18n.fallbacks = true + + # Send deprecation notices to registered listeners. + config.active_support.deprecation = :notify + + # Disable automatic flushing of the log to improve performance. + # config.autoflush_log = false + + # Use default logging formatter so that PID and timestamp are not suppressed. + #config.log_formatter = ::Logger::Formatter.new + + # Do not dump schema after migrations. + config.active_record.dump_schema_after_migration = false if config.respond_to?(:active_record) +end diff --git a/src/spec/stub/rails41/config/initializers/assets.rb b/src/spec/stub/rails41/config/initializers/assets.rb new file mode 100644 index 00000000..d2f4ec33 --- /dev/null +++ b/src/spec/stub/rails41/config/initializers/assets.rb @@ -0,0 +1,8 @@ +# Be sure to restart your server when you modify this file. + +# Version of your assets, change this if you want to expire all your assets. +Rails.application.config.assets.version = '1.0' + +# Precompile additional assets. +# application.js, application.css, and all non-JS/CSS in app/assets folder are already added. +# Rails.application.config.assets.precompile += %w( search.js ) diff --git a/src/spec/stub/rails41/config/initializers/backtrace_silencers.rb b/src/spec/stub/rails41/config/initializers/backtrace_silencers.rb new file mode 100644 index 00000000..59385cdf --- /dev/null +++ b/src/spec/stub/rails41/config/initializers/backtrace_silencers.rb @@ -0,0 +1,7 @@ +# Be sure to restart your server when you modify this file. + +# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. +# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } + +# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. +# Rails.backtrace_cleaner.remove_silencers! diff --git a/src/spec/stub/rails41/config/initializers/cookies_serializer.rb b/src/spec/stub/rails41/config/initializers/cookies_serializer.rb new file mode 100644 index 00000000..7a06a89f --- /dev/null +++ b/src/spec/stub/rails41/config/initializers/cookies_serializer.rb @@ -0,0 +1,3 @@ +# Be sure to restart your server when you modify this file. + +Rails.application.config.action_dispatch.cookies_serializer = :json \ No newline at end of file diff --git a/src/spec/stub/rails41/config/initializers/filter_parameter_logging.rb b/src/spec/stub/rails41/config/initializers/filter_parameter_logging.rb new file mode 100644 index 00000000..4a994e1e --- /dev/null +++ b/src/spec/stub/rails41/config/initializers/filter_parameter_logging.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Configure sensitive parameters which will be filtered from the log file. +Rails.application.config.filter_parameters += [:password] diff --git a/src/spec/stub/rails41/config/initializers/inflections.rb b/src/spec/stub/rails41/config/initializers/inflections.rb new file mode 100644 index 00000000..ac033bf9 --- /dev/null +++ b/src/spec/stub/rails41/config/initializers/inflections.rb @@ -0,0 +1,16 @@ +# Be sure to restart your server when you modify this file. + +# Add new inflection rules using the following format. Inflections +# are locale specific, and you may define rules for as many different +# locales as you wish. All of these examples are active by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.plural /^(ox)$/i, '\1en' +# inflect.singular /^(ox)en/i, '\1' +# inflect.irregular 'person', 'people' +# inflect.uncountable %w( fish sheep ) +# end + +# These inflection rules are supported but not enabled by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.acronym 'RESTful' +# end diff --git a/src/spec/stub/rails41/config/initializers/mime_types.rb b/src/spec/stub/rails41/config/initializers/mime_types.rb new file mode 100644 index 00000000..dc189968 --- /dev/null +++ b/src/spec/stub/rails41/config/initializers/mime_types.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Add new mime types for use in respond_to blocks: +# Mime::Type.register "text/richtext", :rtf diff --git a/src/spec/stub/rails41/config/initializers/session_store.rb b/src/spec/stub/rails41/config/initializers/session_store.rb new file mode 100644 index 00000000..080bcea9 --- /dev/null +++ b/src/spec/stub/rails41/config/initializers/session_store.rb @@ -0,0 +1,3 @@ +# Be sure to restart your server when you modify this file. + +Rails.application.config.session_store :cookie_store, key: '_rails41_session' diff --git a/src/spec/stub/rails41/config/initializers/wrap_parameters.rb b/src/spec/stub/rails41/config/initializers/wrap_parameters.rb new file mode 100644 index 00000000..33725e95 --- /dev/null +++ b/src/spec/stub/rails41/config/initializers/wrap_parameters.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. + +# This file contains settings for ActionController::ParamsWrapper which +# is enabled by default. + +# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. +ActiveSupport.on_load(:action_controller) do + wrap_parameters format: [:json] if respond_to?(:wrap_parameters) +end + +# To enable root element in JSON for ActiveRecord objects. +# ActiveSupport.on_load(:active_record) do +# self.include_root_in_json = true +# end diff --git a/src/spec/stub/rails41/config/locales/en.yml b/src/spec/stub/rails41/config/locales/en.yml new file mode 100644 index 00000000..06539571 --- /dev/null +++ b/src/spec/stub/rails41/config/locales/en.yml @@ -0,0 +1,23 @@ +# Files in the config/locales directory are used for internationalization +# and are automatically loaded by Rails. If you want to use locales other +# than English, add the necessary files in this directory. +# +# To use the locales, use `I18n.t`: +# +# I18n.t 'hello' +# +# In views, this is aliased to just `t`: +# +# <%= t('hello') %> +# +# To use a different locale, set it with `I18n.locale`: +# +# I18n.locale = :es +# +# This would use the information in config/locales/es.yml. +# +# To learn more, please read the Rails Internationalization guide +# available at http://guides.rubyonrails.org/i18n.html. + +en: + hello: "Hello world" diff --git a/src/spec/stub/rails41/config/routes.rb b/src/spec/stub/rails41/config/routes.rb new file mode 100644 index 00000000..3f66539d --- /dev/null +++ b/src/spec/stub/rails41/config/routes.rb @@ -0,0 +1,56 @@ +Rails.application.routes.draw do + # The priority is based upon order of creation: first created -> highest priority. + # See how all your routes lay out with "rake routes". + + # You can have the root of your site routed with "root" + # root 'welcome#index' + + # Example of regular route: + # get 'products/:id' => 'catalog#view' + + # Example of named route that can be invoked with purchase_url(id: product.id) + # get 'products/:id/purchase' => 'catalog#purchase', as: :purchase + + # Example resource route (maps HTTP verbs to controller actions automatically): + # resources :products + + # Example resource route with options: + # resources :products do + # member do + # get 'short' + # post 'toggle' + # end + # + # collection do + # get 'sold' + # end + # end + + # Example resource route with sub-resources: + # resources :products do + # resources :comments, :sales + # resource :seller + # end + + # Example resource route with more complex sub-resources: + # resources :products do + # resources :comments + # resources :sales do + # get 'recent', on: :collection + # end + # end + + # Example resource route with concerns: + # concern :toggleable do + # post 'toggle' + # end + # resources :posts, concerns: :toggleable + # resources :photos, concerns: :toggleable + + # Example resource route within a namespace: + # namespace :admin do + # # Directs /admin/products/* to Admin::ProductsController + # # (app/controllers/admin/products_controller.rb) + # resources :products + # end +end diff --git a/src/spec/stub/rails41/config/secrets.yml b/src/spec/stub/rails41/config/secrets.yml new file mode 100644 index 00000000..fd32b050 --- /dev/null +++ b/src/spec/stub/rails41/config/secrets.yml @@ -0,0 +1,23 @@ +# Be sure to restart your server when you modify this file. + +# Your secret key is used for verifying the integrity of signed cookies. +# If you change this key, all old signed cookies will become invalid! + +# Make sure the secret is at least 30 characters and all random, +# no regular words or you'll be exposed to dictionary attacks. +# You can use `rake secret` to generate a secure secret key. + +# Make sure the secrets in this file are kept private +# if you're sharing your code publicly. + +development: + secret_key_base: a9f5a1ab3bfafbb54440df7a8ae935c708164c069e96564617ed1aa4667478afea1ac0e4af1eba9b178820ab56c4caa317d9816e0ecbb0fecdee55946e64e3d3 + +<% if ENV["SECRET_KEY_BASE"] %> +# Do not keep production secrets in the repository, +# instead read values from the environment. +production: + secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> +<% else %> + +<% end %> diff --git a/src/spec/stub/rails41/db/seeds.rb b/src/spec/stub/rails41/db/seeds.rb new file mode 100644 index 00000000..4edb1e85 --- /dev/null +++ b/src/spec/stub/rails41/db/seeds.rb @@ -0,0 +1,7 @@ +# This file should contain all the record creation needed to seed the database with its default values. +# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). +# +# Examples: +# +# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) +# Mayor.create(name: 'Emanuel', city: cities.first) diff --git a/src/spec/stub/rails41/lib/assets/.keep b/src/spec/stub/rails41/lib/assets/.keep new file mode 100644 index 00000000..e69de29b diff --git a/src/spec/stub/rails41/lib/tasks/.keep b/src/spec/stub/rails41/lib/tasks/.keep new file mode 100644 index 00000000..e69de29b diff --git a/src/spec/stub/rails41/public/404.html b/src/spec/stub/rails41/public/404.html new file mode 100644 index 00000000..b612547f --- /dev/null +++ b/src/spec/stub/rails41/public/404.html @@ -0,0 +1,67 @@ + + + + The page you were looking for doesn't exist (404) + + + + + + +
+
+

The page you were looking for doesn't exist.

+

You may have mistyped the address or the page may have moved.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/src/spec/stub/rails41/public/422.html b/src/spec/stub/rails41/public/422.html new file mode 100644 index 00000000..a21f82b3 --- /dev/null +++ b/src/spec/stub/rails41/public/422.html @@ -0,0 +1,67 @@ + + + + The change you wanted was rejected (422) + + + + + + +
+
+

The change you wanted was rejected.

+

Maybe you tried to change something you didn't have access to.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/src/spec/stub/rails41/public/500.html b/src/spec/stub/rails41/public/500.html new file mode 100644 index 00000000..061abc58 --- /dev/null +++ b/src/spec/stub/rails41/public/500.html @@ -0,0 +1,66 @@ + + + + We're sorry, but something went wrong (500) + + + + + + +
+
+

We're sorry, but something went wrong.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/src/spec/stub/rails41/public/robots.txt b/src/spec/stub/rails41/public/robots.txt new file mode 100644 index 00000000..3c9c7c01 --- /dev/null +++ b/src/spec/stub/rails41/public/robots.txt @@ -0,0 +1,5 @@ +# See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file +# +# To ban all spiders from the entire site uncomment the next two lines: +# User-agent: * +# Disallow: / diff --git a/src/spec/stub/rails41/vendor/assets/javascripts/.keep b/src/spec/stub/rails41/vendor/assets/javascripts/.keep new file mode 100644 index 00000000..e69de29b diff --git a/src/spec/stub/rails41/vendor/assets/stylesheets/.keep b/src/spec/stub/rails41/vendor/assets/stylesheets/.keep new file mode 100644 index 00000000..e69de29b From 01fbc0f27566d2ad564558799c0bb4becfac8a14 Mon Sep 17 00:00:00 2001 From: kares Date: Mon, 12 Jan 2015 07:04:15 +0100 Subject: [PATCH 25/27] note that ErrorApp::ShowStatus is not public API + delay rack loading --- src/main/ruby/jruby/rack/error_app/show_status.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/ruby/jruby/rack/error_app/show_status.rb b/src/main/ruby/jruby/rack/error_app/show_status.rb index 835f3d25..8adf37a6 100644 --- a/src/main/ruby/jruby/rack/error_app/show_status.rb +++ b/src/main/ruby/jruby/rack/error_app/show_status.rb @@ -1,15 +1,15 @@ require 'erb' -require 'rack/request' -require 'rack/utils' class JRuby::Rack::ErrorApp # catches empty responses and replaces them with a site explaining the error. # # @note kindly adapted from on Rack::ShowStatus + # @private internal API - likely won't exist in 1.2.x class ShowStatus def initialize(app) + require 'rack/request'; require 'rack/utils' @app = app @template = ERB.new(TEMPLATE) end From c801c8e5b4f39e6e7a03ca58e5cf72713ee0ed0e Mon Sep 17 00:00:00 2001 From: kares Date: Tue, 13 Jan 2015 15:08:46 +0100 Subject: [PATCH 26/27] prepare for 1.1.18 --- History.md | 11 +++++++++++ pom.xml | 2 +- src/main/ruby/jruby/rack/version.rb | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/History.md b/History.md index 0d423fcc..c64169d1 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,14 @@ +## 1.1.18 (13/01/15) + +- back-port Rack::ShowStatus to be used with out ErrorApp (contains XSS fix #190) +- search rackup (config.ru) on context-classloader if not found elsewhere +- introduce a new ClassPathLayout where the whole app + gems are on CP (#191) +- update to (vendored) rack ~> 1.5.2 (for JRuby-Rack 1.1.x) +- use Rack::Utils.best_q_match in ErrorApp if available +- improved rack-compatibility for our "pure" servlet-env request env parsing + * raise a TypeError just like rack does when it detects invalid parameters + * compatibility with rack's parse_nested_query logic + ## 1.1.17 (30/12/14) This release changes deployment from codehaus.org to oss.sonatype.org for artifacts. diff --git a/pom.xml b/pom.xml index 79c3aa8a..9a93bfa3 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ org.jruby.rack jruby-rack - 1.1.18-SNAPSHOT + 1.1.18 JRuby-Rack http://github.com/jruby/jruby-rack/ diff --git a/src/main/ruby/jruby/rack/version.rb b/src/main/ruby/jruby/rack/version.rb index a32635a7..26fc82e6 100644 --- a/src/main/ruby/jruby/rack/version.rb +++ b/src/main/ruby/jruby/rack/version.rb @@ -7,6 +7,6 @@ module JRuby module Rack - VERSION = '1.1.18.SNAPSHOT' + VERSION = '1.1.18' end end From 0320907b1ace7ac1a32dcf91d44e8b0f2cdd7689 Mon Sep 17 00:00:00 2001 From: kares Date: Tue, 13 Jan 2015 15:29:54 +0100 Subject: [PATCH 27/27] update for next development snapshot --- pom.xml | 2 +- src/main/ruby/jruby/rack/version.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 9a93bfa3..8cc291f5 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ org.jruby.rack jruby-rack - 1.1.18 + 1.1.19-SNAPSHOT JRuby-Rack http://github.com/jruby/jruby-rack/ diff --git a/src/main/ruby/jruby/rack/version.rb b/src/main/ruby/jruby/rack/version.rb index 26fc82e6..e7cd380d 100644 --- a/src/main/ruby/jruby/rack/version.rb +++ b/src/main/ruby/jruby/rack/version.rb @@ -7,6 +7,6 @@ module JRuby module Rack - VERSION = '1.1.18' + VERSION = '1.1.19.SNAPSHOT' end end