mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
drb: use \A and \z
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61516 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
ff9a3de4b3
commit
d83e02017e
4 changed files with 14 additions and 8 deletions
|
@ -800,7 +800,7 @@ module DRb
|
||||||
module_function :uri_option
|
module_function :uri_option
|
||||||
|
|
||||||
def auto_load(uri) # :nodoc:
|
def auto_load(uri) # :nodoc:
|
||||||
if uri =~ /^drb([a-z0-9]+):/
|
if /\Adrb([a-z0-9]+):/ =~ uri
|
||||||
require("drb/#{$1}") rescue nil
|
require("drb/#{$1}") rescue nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -816,13 +816,13 @@ module DRb
|
||||||
# :stopdoc:
|
# :stopdoc:
|
||||||
private
|
private
|
||||||
def self.parse_uri(uri)
|
def self.parse_uri(uri)
|
||||||
if uri =~ /^druby:\/\/(.*?):(\d+)(\?(.*))?$/
|
if /\Adruby:\/\/(.*?):(\d+)(\?(.*))?\z/ =~ uri
|
||||||
host = $1
|
host = $1
|
||||||
port = $2.to_i
|
port = $2.to_i
|
||||||
option = $4
|
option = $4
|
||||||
[host, port, option]
|
[host, port, option]
|
||||||
else
|
else
|
||||||
raise(DRbBadScheme, uri) unless uri =~ /^druby:/
|
raise(DRbBadScheme, uri) unless uri.start_with?('druby:')
|
||||||
raise(DRbBadURI, 'can\'t parse uri:' + uri)
|
raise(DRbBadURI, 'can\'t parse uri:' + uri)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1172,7 +1172,7 @@ module DRb
|
||||||
bt = []
|
bt = []
|
||||||
result.backtrace.each do |x|
|
result.backtrace.each do |x|
|
||||||
break if /`__send__'$/ =~ x
|
break if /`__send__'$/ =~ x
|
||||||
if /^\(druby:\/\// =~ x
|
if /\A\(druby:\/\// =~ x
|
||||||
bt.push(x)
|
bt.push(x)
|
||||||
else
|
else
|
||||||
bt.push(prefix + x)
|
bt.push(prefix + x)
|
||||||
|
|
|
@ -226,13 +226,13 @@ module DRb
|
||||||
#
|
#
|
||||||
# Raises DRbBadScheme or DRbBadURI if +uri+ is not matching or malformed
|
# Raises DRbBadScheme or DRbBadURI if +uri+ is not matching or malformed
|
||||||
def self.parse_uri(uri) # :nodoc:
|
def self.parse_uri(uri) # :nodoc:
|
||||||
if uri =~ /^drbssl:\/\/(.*?):(\d+)(\?(.*))?$/
|
if /\Adrbssl:\/\/(.*?):(\d+)(\?(.*))?\z/ =~ uri
|
||||||
host = $1
|
host = $1
|
||||||
port = $2.to_i
|
port = $2.to_i
|
||||||
option = $4
|
option = $4
|
||||||
[host, port, option]
|
[host, port, option]
|
||||||
else
|
else
|
||||||
raise(DRbBadScheme, uri) unless uri =~ /^drbssl:/
|
raise(DRbBadScheme, uri) unless uri.start_with?('drbssl:')
|
||||||
raise(DRbBadURI, 'can\'t parse uri:' + uri)
|
raise(DRbBadURI, 'can\'t parse uri:' + uri)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -15,12 +15,12 @@ module DRb
|
||||||
class DRbUNIXSocket < DRbTCPSocket
|
class DRbUNIXSocket < DRbTCPSocket
|
||||||
# :stopdoc:
|
# :stopdoc:
|
||||||
def self.parse_uri(uri)
|
def self.parse_uri(uri)
|
||||||
if /^drbunix:(.*?)(\?(.*))?$/ =~ uri
|
if /\Adrbunix:(.*?)(\?(.*))?\z/ =~ uri
|
||||||
filename = $1
|
filename = $1
|
||||||
option = $3
|
option = $3
|
||||||
[filename, option]
|
[filename, option]
|
||||||
else
|
else
|
||||||
raise(DRbBadScheme, uri) unless uri =~ /^drbunix:/
|
raise(DRbBadScheme, uri) unless uri.start_with?('drbunix:')
|
||||||
raise(DRbBadURI, 'can\'t parse uri:' + uri)
|
raise(DRbBadURI, 'can\'t parse uri:' + uri)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -40,6 +40,12 @@ class TestDRbUNIXCore < Test::Unit::TestCase
|
||||||
|
|
||||||
def test_05_eq
|
def test_05_eq
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_bad_uri
|
||||||
|
assert_raise(DRb::DRbBadURI) do
|
||||||
|
DRb::DRbServer.new("badfile\n""drbunix:")
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class TestDRbUNIXAry < Test::Unit::TestCase
|
class TestDRbUNIXAry < Test::Unit::TestCase
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue