Skip to content

Commit 1dadea0

Browse files
committed
Changes to make things appear to work in opal
1 parent 0b3f997 commit 1dadea0

File tree

11 files changed

+37
-40
lines changed

11 files changed

+37
-40
lines changed

lib/rack/auth/digest.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
require_relative 'abstract/handler'
44
require_relative 'abstract/request'
5-
require 'digest/md5'
5+
# require 'digest/md5'
66
require 'base64'
77

88
module Rack

lib/rack/deflater.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# frozen_string_literal: true
22

3-
require "zlib"
3+
# require "zlib"
44
require "time" # for Time.httpdate
55

66
require_relative 'constants'

lib/rack/etag.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# frozen_string_literal: true
22

3-
require 'digest/sha2'
3+
# require 'digest/sha2'
44

55
require_relative 'constants'
66
require_relative 'utils'

lib/rack/lint.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -316,9 +316,9 @@ def check_environment(env)
316316
raise LintError, "env variable #{key} has non-string value #{value.inspect}"
317317
end
318318
next if value.encoding == Encoding::ASCII_8BIT
319-
unless value.b !~ /[\x80-\xff]/n
320-
raise LintError, "env variable #{key} has value containing non-ASCII characters and has non-ASCII-8BIT encoding #{value.inspect} encoding: #{value.encoding}"
321-
end
319+
# unless value.b !~ /[\x80-\xff]/n
320+
# raise LintError, "env variable #{key} has value containing non-ASCII characters and has non-ASCII-8BIT encoding #{value.inspect} encoding: #{value.encoding}"
321+
# end
322322
}
323323

324324
## There are the following restrictions:

lib/rack/mock_response.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# frozen_string_literal: true
22

3-
require 'cgi/cookie'
3+
# require 'cgi/cookie'
44
require 'time'
55

66
require_relative 'response'

lib/rack/multipart/parser.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ def get_filename(head)
388388
end
389389

390390
CHARSET = "charset"
391-
deprecate_constant :CHARSET
391+
# deprecate_constant :CHARSET
392392

393393
def tag_multipart_encoding(filename, content_type, name, body)
394394
name = name.to_s

lib/rack/multipart/uploaded_file.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# frozen_string_literal: true
22

3-
require 'tempfile'
3+
# require 'tempfile'
44
require 'fileutils'
55

66
module Rack

lib/rack/request.rb

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,17 @@ class << self
4545

4646
valid_ipv4_octet = /\.(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])/
4747

48-
trusted_proxies = Regexp.union(
48+
trusted_proxies = [
4949
/\A127#{valid_ipv4_octet}{3}\z/, # localhost IPv4 range 127.x.x.x, per RFC-3330
5050
/\A::1\z/, # localhost IPv6 ::1
5151
/\Af[cd][0-9a-f]{2}(?::[0-9a-f]{0,4}){0,7}\z/i, # private IPv6 range fc00 .. fdff
5252
/\A10#{valid_ipv4_octet}{3}\z/, # private IPv4 range 10.x.x.x
5353
/\A172\.(1[6-9]|2[0-9]|3[01])#{valid_ipv4_octet}{2}\z/, # private IPv4 range 172.16.0.0 .. 172.31.255.255
5454
/\A192\.168#{valid_ipv4_octet}{2}\z/, # private IPv4 range 192.168.x.x
5555
/\Alocalhost\z|\Aunix(\z|:)/i, # localhost hostname, and unix domain sockets
56-
)
56+
]
5757

58-
self.ip_filter = lambda { |ip| trusted_proxies.match?(ip) }
58+
self.ip_filter = lambda { |ip| trusted_proxies.select { |tp| tp.match?(ip) }.any? }
5959

6060
ALLOWED_SCHEMES = %w(https http wss ws).freeze
6161

@@ -678,34 +678,31 @@ def split_header(value)
678678

679679
# ipv6 extracted from resolv stdlib, simplified
680680
# to remove numbered match group creation.
681-
ipv6 = Regexp.union(
682-
/(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# (?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4})*)? ::
697+
# (?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4})*)?
698+
# |
699+
# :(?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4})*)?
700+
# )?
701+
# :[0-9A-Fa-f]{1,4}%[-0-9A-Za-z._~]+/x)
702702

703703
AUTHORITY = /
704704
\A
705705
(?<host>
706-
# Match IPv6 as a string of hex digits and colons in square brackets
707-
\[(?<address>#{ipv6})\]
708-
|
709706
# Match any other printable string (except square brackets) as a hostname
710707
(?<address>[[[:graph:]&&[^\[\]]]]*?)
711708
)

lib/rack/rewindable_input.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- encoding: binary -*-
22
# frozen_string_literal: true
33

4-
require 'tempfile'
4+
# require 'tempfile'
55

66
require_relative 'constants'
77

lib/rack/utils.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
require 'uri'
55
require 'fileutils'
66
require 'set'
7-
require 'tempfile'
7+
# require 'tempfile'
88
require 'time'
99

1010
require_relative 'query_parser'

0 commit comments

Comments
 (0)