1
0
Fork 0
mirror of https://github.com/puma/puma.git synced 2022-11-09 13:48:40 -05:00

Remove support for 1.8.7 and 1.9.2.

This commit is contained in:
Francesco Rodriguez 2016-09-01 23:57:38 +02:00
parent 71007dfe81
commit 69710ab4a4
8 changed files with 15 additions and 142 deletions

View file

@ -51,8 +51,6 @@ lib/puma/minissl.rb
lib/puma/null_io.rb
lib/puma/plugin.rb
lib/puma/plugin/tmp_restart.rb
lib/puma/rack/backports/uri/common_18.rb
lib/puma/rack/backports/uri/common_192.rb
lib/puma/rack/backports/uri/common_193.rb
lib/puma/rack/builder.rb
lib/puma/rack/urlmap.rb

View file

@ -18,7 +18,7 @@ HOE = Hoe.spec "puma" do
spec_extras[:executables] = ['puma', 'pumactl']
spec_extras[:homepage] = self.urls.first
require_ruby_version ">= 1.8.7"
require_ruby_version ">= 1.9.3"
dependency "rack", [">= 1.1", "< 2.0"], :development
@ -155,4 +155,3 @@ namespace :test do
task :all => [:test, "test:integration"]
end
end

View file

@ -291,7 +291,7 @@ module Puma
raise HttpParserError,
"HEADER is longer than allowed, aborting client early."
end
false
end

View file

@ -6,13 +6,9 @@ class String
end
unless method_defined? :byteslice
if RUBY_VERSION < '1.9'
alias_method :byteslice, :[]
else
def byteslice(*arg)
enc = self.encoding
self.dup.force_encoding(Encoding::ASCII_8BIT).slice(*arg).force_encoding(enc)
end
def byteslice(*arg)
enc = self.encoding
self.dup.force_encoding(Encoding::ASCII_8BIT).slice(*arg).force_encoding(enc)
end
end
end

View file

@ -1,59 +0,0 @@
# :stopdoc:
# Stolen from ruby core's uri/common.rb, with modifications to support 1.8.x
#
# https://github.com/ruby/ruby/blob/trunk/lib/uri/common.rb
#
#
module URI
begin
TBLENCWWWCOMP_ = {} # :nodoc:
256.times do |i|
TBLENCWWWCOMP_[i.chr] = '%%%02X' % i
end
TBLENCWWWCOMP_[' '] = '+'
TBLENCWWWCOMP_.freeze
TBLDECWWWCOMP_ = {} # :nodoc:
256.times do |i|
h, l = i>>4, i&15
TBLDECWWWCOMP_['%%%X%X' % [h, l]] = i.chr
TBLDECWWWCOMP_['%%%x%X' % [h, l]] = i.chr
TBLDECWWWCOMP_['%%%X%x' % [h, l]] = i.chr
TBLDECWWWCOMP_['%%%x%x' % [h, l]] = i.chr
end
TBLDECWWWCOMP_['+'] = ' '
TBLDECWWWCOMP_.freeze
rescue Exception
end
# Encode given +s+ to URL-encoded form data.
#
# This method doesn't convert *, -, ., 0-9, A-Z, _, a-z, but does convert SP
# (ASCII space) to + and converts others to %XX.
#
# This is an implementation of
# http://www.w3.org/TR/html5/forms.html#url-encoded-form-data
#
# See URI.decode_www_form_component, URI.encode_www_form
def self.encode_www_form_component(s)
str = s.to_s
if RUBY_VERSION < "1.9" && $KCODE =~ /u/i
str.gsub(/([^ a-zA-Z0-9_.-]+)/) do
'%' + $1.unpack('H2' * Rack::Utils.bytesize($1)).join('%').upcase
end.tr(' ', '+')
else
str.gsub(/[^*\-.0-9A-Z_a-z]/) {|m| TBLENCWWWCOMP_[m]}
end
end
# Decode given +str+ of URL-encoded form data.
#
# This decodes + to SP.
#
# See URI.encode_www_form_component, URI.decode_www_form
def self.decode_www_form_component(str, enc=nil)
raise ArgumentError, "invalid %-encoding (#{str})" unless /\A(?:%[0-9a-fA-F]{2}|[^%])*\z/ =~ str
str.gsub(/\+|%[0-9a-fA-F]{2}/) {|m| TBLDECWWWCOMP_[m]}
end
end

View file

@ -1,55 +0,0 @@
# :stopdoc:
# Stolen from ruby core's uri/common.rb @32618ba to fix DoS issues in 1.9.2
#
# https://github.com/ruby/ruby/blob/32618ba7438a2247042bba9b5d85b5d49070f5e5/lib/uri/common.rb
#
# Issue:
# http://redmine.ruby-lang.org/issues/5149
#
# Relevant Fixes:
# https://github.com/ruby/ruby/commit/b5f91deee04aa6ccbe07c23c8222b937c22a799b
# https://github.com/ruby/ruby/commit/93177c1e5c3906abf14472ae0b905d8b5c72ce1b
#
# This should probably be removed once there is a Ruby 1.9.2 patch level that
# includes this fix.
require 'uri/common'
module URI
begin
TBLDECWWWCOMP_ = {} unless const_defined?(:TBLDECWWWCOMP_) #:nodoc:
if TBLDECWWWCOMP_.empty?
256.times do |i|
h, l = i>>4, i&15
TBLDECWWWCOMP_['%%%X%X' % [h, l]] = i.chr
TBLDECWWWCOMP_['%%%x%X' % [h, l]] = i.chr
TBLDECWWWCOMP_['%%%X%x' % [h, l]] = i.chr
TBLDECWWWCOMP_['%%%x%x' % [h, l]] = i.chr
end
TBLDECWWWCOMP_['+'] = ' '
TBLDECWWWCOMP_.freeze
end
rescue Exception
end
def self.decode_www_form(str, enc=Encoding::UTF_8)
return [] if str.empty?
unless /\A#{WFKV_}=#{WFKV_}(?:[;&]#{WFKV_}=#{WFKV_})*\z/o =~ str
raise ArgumentError, "invalid data of application/x-www-form-urlencoded (#{str})"
end
ary = []
$&.scan(/([^=;&]+)=([^;&]*)/) do
ary << [decode_www_form_component($1, enc), decode_www_form_component($2, enc)]
end
ary
end
def self.decode_www_form_component(str, enc=Encoding::UTF_8)
raise ArgumentError, "invalid %-encoding (#{str})" unless /\A[^%]*(?:%\h\h[^%]*)*\z/ =~ str
str.gsub(/\+|%\h\h/, TBLDECWWWCOMP_).force_encoding(enc)
end
remove_const :WFKV_ if const_defined?(:WFKV_)
WFKV_ = '(?:[^%#=;&]*(?:%\h\h[^%#=;&]*)*)' # :nodoc:
end

View file

@ -1,10 +1,6 @@
major, minor, patch = RUBY_VERSION.split('.').map { |v| v.to_i }
if major == 1 && minor < 9
require 'puma/rack/backports/uri/common_18'
elsif major == 1 && minor == 9 && patch == 2 && RUBY_PATCHLEVEL <= 328 && RUBY_ENGINE != 'jruby'
require 'puma/rack/backports/uri/common_192'
elsif major == 1 && minor == 9 && patch == 3 && RUBY_PATCHLEVEL < 125
if major == 1 && minor == 9 && patch == 3 && RUBY_PATCHLEVEL < 125
require 'puma/rack/backports/uri/common_193'
else
require 'uri/common'

View file

@ -114,19 +114,17 @@ class TestPumaServerSSL < Test::Unit::TestCase
assert_equal "https", body
end
unless RUBY_VERSION =~ /^1.8/
def test_ssl_v3_rejection
return if DISABLE_SSL
@http.ssl_version='SSLv3'
assert_raises(OpenSSL::SSL::SSLError) do
@http.start do
Net::HTTP::Get.new '/'
end
end
unless defined?(JRUBY_VERSION)
assert_match("wrong version number", @events.error.message) if @events.error
def test_ssl_v3_rejection
return if DISABLE_SSL
@http.ssl_version='SSLv3'
assert_raises(OpenSSL::SSL::SSLError) do
@http.start do
Net::HTTP::Get.new '/'
end
end
unless defined?(JRUBY_VERSION)
assert_match("wrong version number", @events.error.message) if @events.error
end
end
end