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

ruby-changes:59879

From: Nobuyoshi <ko1@a...>
Date: Thu, 30 Jan 2020 12:05:46 +0900 (JST)
Subject: [ruby-changes:59879] e6334fd450 (master): Unnamed groups are not captured when named groups are used

https://git.ruby-lang.org/ruby.git/commit/?id=e6334fd450

From e6334fd45064cb720399bf6aa75116ec62a88357 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Thu, 30 Jan 2020 12:04:15 +0900
Subject: Unnamed groups are not captured when named groups are used


diff --git a/lib/net/ftp.rb b/lib/net/ftp.rb
index d1e545c..1f6879d 100644
--- a/lib/net/ftp.rb
+++ b/lib/net/ftp.rb
@@ -1044,7 +1044,7 @@ module Net https://github.com/ruby/ruby/blob/trunk/lib/net/ftp.rb#L1044
     TIME_PARSER = ->(value, local = false) {
       unless /\A(?<year>\d{4})(?<month>\d{2})(?<day>\d{2})
             (?<hour>\d{2})(?<min>\d{2})(?<sec>\d{2})
-            (\.(?<fractions>\d+))?/x =~ value
+            (?:\.(?<fractions>\d+))?/x =~ value
         raise FTPProtoError, "invalid time-val: #{value}"
       end
       usec = fractions.to_i * 10 ** (6 - fractions.to_s.size)
@@ -1369,7 +1369,7 @@ module Net https://github.com/ruby/ruby/blob/trunk/lib/net/ftp.rb#L1369
       if !resp.start_with?("227")
         raise FTPReplyError, resp
       end
-      if m = /\((?<host>\d+(,\d+){3}),(?<port>\d+,\d+)\)/.match(resp)
+      if m = /\((?<host>\d+(?:,\d+){3}),(?<port>\d+,\d+)\)/.match(resp)
         return parse_pasv_ipv4_host(m["host"]), parse_pasv_port(m["port"])
       else
         raise FTPProtoError, resp
@@ -1385,9 +1385,9 @@ module Net https://github.com/ruby/ruby/blob/trunk/lib/net/ftp.rb#L1385
       if !resp.start_with?("228")
         raise FTPReplyError, resp
       end
-      if m = /\(4,4,(?<host>\d+(,\d+){3}),2,(?<port>\d+,\d+)\)/.match(resp)
+      if m = /\(4,4,(?<host>\d+(?:,\d+){3}),2,(?<port>\d+,\d+)\)/.match(resp)
         return parse_pasv_ipv4_host(m["host"]), parse_pasv_port(m["port"])
-      elsif m = /\(6,16,(?<host>\d+(,(\d+)){15}),2,(?<port>\d+,\d+)\)/.match(resp)
+      elsif m = /\(6,16,(?<host>\d+(?:,\d+){15}),2,(?<port>\d+,\d+)\)/.match(resp)
         return parse_pasv_ipv6_host(m["host"]), parse_pasv_port(m["port"])
       else
         raise FTPProtoError, resp
-- 
cgit v0.10.2


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

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