summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakashi Kokubun <takashikkbn@gmail.com>2024-11-04 14:37:14 -0800
committerTakashi Kokubun <takashikkbn@gmail.com>2024-11-04 14:37:14 -0800
commit34a0f41d0aaff190f1647a6fa0e905690d0eff98 (patch)
treee8e2d081b012d6325a83a744a5d39718435d15e1
parent2b713dcb89c620daa55d672d2933ffde333ca5de (diff)
merge revision(s) c1862cbb89a6bf42dcd07d92fe4f4bfeebca5775: [Backport #20719]
[Bug #20719] `Float` argument must be ASCII compatible
-rw-r--r--object.c1
-rw-r--r--test/ruby/test_float.rb6
-rw-r--r--version.h2
3 files changed, 8 insertions, 1 deletions
diff --git a/object.c b/object.c
index b5decf0c24..5d6b6dbad1 100644
--- a/object.c
+++ b/object.c
@@ -3489,6 +3489,7 @@ rb_str_to_dbl_raise(VALUE str, int badcheck, int raise, int *error)
VALUE v = 0;
StringValue(str);
+ rb_must_asciicompat(str);
s = RSTRING_PTR(str);
len = RSTRING_LEN(str);
if (s) {
diff --git a/test/ruby/test_float.rb b/test/ruby/test_float.rb
index 415d62467e..a0b9b44464 100644
--- a/test/ruby/test_float.rb
+++ b/test/ruby/test_float.rb
@@ -850,6 +850,12 @@ class TestFloat < Test::Unit::TestCase
o = Object.new
def o.to_f; inf = Float::INFINITY; inf/inf; end
assert_predicate(Float(o), :nan?)
+
+ assert_raise(Encoding::CompatibilityError) {Float("0".encode("utf-16be"))}
+ assert_raise(Encoding::CompatibilityError) {Float("0".encode("utf-16le"))}
+ assert_raise(Encoding::CompatibilityError) {Float("0".encode("utf-32be"))}
+ assert_raise(Encoding::CompatibilityError) {Float("0".encode("utf-32le"))}
+ assert_raise(Encoding::CompatibilityError) {Float("0".encode("iso-2022-jp"))}
end
def test_invalid_str
diff --git a/version.h b/version.h
index 43e825a570..9be17cfcf1 100644
--- a/version.h
+++ b/version.h
@@ -11,7 +11,7 @@
# define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR
#define RUBY_VERSION_TEENY 5
#define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR
-#define RUBY_PATCHLEVEL 103
+#define RUBY_PATCHLEVEL 104
#include "ruby/version.h"
#include "ruby/internal/abi.h"