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
|
||||
|
||||
def auto_load(uri) # :nodoc:
|
||||
if uri =~ /^drb([a-z0-9]+):/
|
||||
if /\Adrb([a-z0-9]+):/ =~ uri
|
||||
require("drb/#{$1}") rescue nil
|
||||
end
|
||||
end
|
||||
|
@ -816,13 +816,13 @@ module DRb
|
|||
# :stopdoc:
|
||||
private
|
||||
def self.parse_uri(uri)
|
||||
if uri =~ /^druby:\/\/(.*?):(\d+)(\?(.*))?$/
|
||||
if /\Adruby:\/\/(.*?):(\d+)(\?(.*))?\z/ =~ uri
|
||||
host = $1
|
||||
port = $2.to_i
|
||||
option = $4
|
||||
[host, port, option]
|
||||
else
|
||||
raise(DRbBadScheme, uri) unless uri =~ /^druby:/
|
||||
raise(DRbBadScheme, uri) unless uri.start_with?('druby:')
|
||||
raise(DRbBadURI, 'can\'t parse uri:' + uri)
|
||||
end
|
||||
end
|
||||
|
@ -1172,7 +1172,7 @@ module DRb
|
|||
bt = []
|
||||
result.backtrace.each do |x|
|
||||
break if /`__send__'$/ =~ x
|
||||
if /^\(druby:\/\// =~ x
|
||||
if /\A\(druby:\/\// =~ x
|
||||
bt.push(x)
|
||||
else
|
||||
bt.push(prefix + x)
|
||||
|
|
|
@ -226,13 +226,13 @@ module DRb
|
|||
#
|
||||
# Raises DRbBadScheme or DRbBadURI if +uri+ is not matching or malformed
|
||||
def self.parse_uri(uri) # :nodoc:
|
||||
if uri =~ /^drbssl:\/\/(.*?):(\d+)(\?(.*))?$/
|
||||
if /\Adrbssl:\/\/(.*?):(\d+)(\?(.*))?\z/ =~ uri
|
||||
host = $1
|
||||
port = $2.to_i
|
||||
option = $4
|
||||
[host, port, option]
|
||||
else
|
||||
raise(DRbBadScheme, uri) unless uri =~ /^drbssl:/
|
||||
raise(DRbBadScheme, uri) unless uri.start_with?('drbssl:')
|
||||
raise(DRbBadURI, 'can\'t parse uri:' + uri)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -15,12 +15,12 @@ module DRb
|
|||
class DRbUNIXSocket < DRbTCPSocket
|
||||
# :stopdoc:
|
||||
def self.parse_uri(uri)
|
||||
if /^drbunix:(.*?)(\?(.*))?$/ =~ uri
|
||||
if /\Adrbunix:(.*?)(\?(.*))?\z/ =~ uri
|
||||
filename = $1
|
||||
option = $3
|
||||
[filename, option]
|
||||
else
|
||||
raise(DRbBadScheme, uri) unless uri =~ /^drbunix:/
|
||||
raise(DRbBadScheme, uri) unless uri.start_with?('drbunix:')
|
||||
raise(DRbBadURI, 'can\'t parse uri:' + uri)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -40,6 +40,12 @@ class TestDRbUNIXCore < Test::Unit::TestCase
|
|||
|
||||
def test_05_eq
|
||||
end
|
||||
|
||||
def test_bad_uri
|
||||
assert_raise(DRb::DRbBadURI) do
|
||||
DRb::DRbServer.new("badfile\n""drbunix:")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class TestDRbUNIXAry < Test::Unit::TestCase
|
||||
|
|
Loading…
Add table
Reference in a new issue