summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-12-23 03:22:57 +0000
committershyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-12-23 03:22:57 +0000
commit196d4a7d730eceaf2b9719a44d4c9778102e5724 (patch)
tree14019e1d6f5e01e7ec8554b379e1b61efe9b2e55
parent2d0d54f228bdb61eac1cf17d5e8c58c54858a9ae (diff)
merge revision(s) 30302:
* lib/resolv.rb (Resolv::IPv4::Regex): make it only accept 0 to 255. [ruby-core:29501] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_7@30303 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--lib/resolv.rb6
-rw-r--r--test/resolv/test_addr.rb16
-rw-r--r--version.h8
4 files changed, 30 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index bb7478e..af54a07 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Thu Dec 23 12:22:35 2010 Tanaka Akira <akr@fsij.org>
+
+ * lib/resolv.rb (Resolv::IPv4::Regex): make it only accept 0 to 255.
+ [ruby-core:29501]
+
Tue Dec 21 01:43:01 2010 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
* lib/webrick/https.rb: uninitialized instance variables.
diff --git a/lib/resolv.rb b/lib/resolv.rb
index 5a4275f..5cc0313 100644
--- a/lib/resolv.rb
+++ b/lib/resolv.rb
@@ -2066,7 +2066,11 @@ class Resolv
##
# Regular expression IPv4 addresses must match.
- Regex = /\A(\d+)\.(\d+)\.(\d+)\.(\d+)\z/
+ Regex256 = /0
+ |1(?:[0-9][0-9]?)?
+ |2(?:[0-4][0-9]?|5[0-5]?|[6-9])?
+ |[3-9][0-9]?/x
+ Regex = /\A(#{Regex256})\.(#{Regex256})\.(#{Regex256})\.(#{Regex256})\z/
def self.create(arg)
case arg
diff --git a/test/resolv/test_addr.rb b/test/resolv/test_addr.rb
new file mode 100644
index 0000000..5103f16
--- /dev/null
+++ b/test/resolv/test_addr.rb
@@ -0,0 +1,16 @@
+require 'test/unit'
+require 'resolv'
+require 'socket'
+
+class TestResolvAddr < Test::Unit::TestCase
+ def test_invalid_ipv4_address
+ assert(Resolv::IPv4::Regex !~ "1.2.3.256", "[ruby-core:29501]")
+ 1000.times {|i|
+ if i < 256
+ assert(Resolv::IPv4::Regex =~ "#{i}.#{i}.#{i}.#{i}")
+ else
+ assert(Resolv::IPv4::Regex !~ "#{i}.#{i}.#{i}.#{i}")
+ end
+ }
+ end
+end
diff --git a/version.h b/version.h
index daf87da..e1dc2d0 100644
--- a/version.h
+++ b/version.h
@@ -1,15 +1,15 @@
#define RUBY_VERSION "1.8.7"
-#define RUBY_RELEASE_DATE "2010-12-21"
+#define RUBY_RELEASE_DATE "2010-12-23"
#define RUBY_VERSION_CODE 187
-#define RUBY_RELEASE_CODE 20101221
-#define RUBY_PATCHLEVEL 329
+#define RUBY_RELEASE_CODE 20101223
+#define RUBY_PATCHLEVEL 330
#define RUBY_VERSION_MAJOR 1
#define RUBY_VERSION_MINOR 8
#define RUBY_VERSION_TEENY 7
#define RUBY_RELEASE_YEAR 2010
#define RUBY_RELEASE_MONTH 12
-#define RUBY_RELEASE_DAY 21
+#define RUBY_RELEASE_DAY 23
#ifdef RUBY_EXTERN
RUBY_EXTERN const char ruby_version[];