[前][次][番号順一覧][スレッド一覧]

ruby-changes:49400

From: nobu <ko1@a...>
Date: Sat, 30 Dec 2017 21:10:50 +0900 (JST)
Subject: [ruby-changes:49400] nobu:r61516 (trunk): drb: use \A and \z

nobu	2017-12-30 21:10:43 +0900 (Sat, 30 Dec 2017)

  New Revision: 61516

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=61516

  Log:
    drb: use \A and \z

  Modified files:
    trunk/lib/drb/drb.rb
    trunk/lib/drb/ssl.rb
    trunk/lib/drb/unix.rb
    trunk/test/drb/test_drbunix.rb
Index: test/drb/test_drbunix.rb
===================================================================
--- test/drb/test_drbunix.rb	(revision 61515)
+++ test/drb/test_drbunix.rb	(revision 61516)
@@ -40,6 +40,12 @@ class TestDRbUNIXCore < Test::Unit::Test https://github.com/ruby/ruby/blob/trunk/test/drb/test_drbunix.rb#L40
 
   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
Index: lib/drb/ssl.rb
===================================================================
--- lib/drb/ssl.rb	(revision 61515)
+++ lib/drb/ssl.rb	(revision 61516)
@@ -226,13 +226,13 @@ module DRb https://github.com/ruby/ruby/blob/trunk/lib/drb/ssl.rb#L226
     #
     # 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
Index: lib/drb/unix.rb
===================================================================
--- lib/drb/unix.rb	(revision 61515)
+++ lib/drb/unix.rb	(revision 61516)
@@ -15,12 +15,12 @@ module DRb https://github.com/ruby/ruby/blob/trunk/lib/drb/unix.rb#L15
   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
Index: lib/drb/drb.rb
===================================================================
--- lib/drb/drb.rb	(revision 61515)
+++ lib/drb/drb.rb	(revision 61516)
@@ -800,7 +800,7 @@ module DRb https://github.com/ruby/ruby/blob/trunk/lib/drb/drb.rb#L800
     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 https://github.com/ruby/ruby/blob/trunk/lib/drb/drb.rb#L816
     # :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 https://github.com/ruby/ruby/blob/trunk/lib/drb/drb.rb#L1172
       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)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]