From 79eb75a8dd64848f23e9efc465f06326b5d4b680 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 29 Nov 2023 14:40:21 +0900 Subject: [PATCH] [Bug #20025] Check if upper/lower before fallback to case-folding --- symbol.c | 4 ++-- test/-ext-/symbol/test_type.rb | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/symbol.c b/symbol.c index 2447b1ec10..6a0c926db8 100644 --- a/symbol.c +++ b/symbol.c @@ -225,10 +225,10 @@ rb_sym_constant_char_p(const char *name, long nlen, rb_encoding *enc) if (!MBCLEN_CHARFOUND_P(c)) return FALSE; len = MBCLEN_CHARFOUND_LEN(c); c = rb_enc_mbc_to_codepoint(name, end, enc); + if (rb_enc_isupper(c, enc)) return TRUE; + if (rb_enc_islower(c, enc)) return FALSE; if (ONIGENC_IS_UNICODE(enc)) { static int ctype_titlecase = 0; - if (rb_enc_isupper(c, enc)) return TRUE; - if (rb_enc_islower(c, enc)) return FALSE; if (!ctype_titlecase) { static const UChar cname[] = "titlecaseletter"; static const UChar *const end = cname + sizeof(cname) - 1; diff --git a/test/-ext-/symbol/test_type.rb b/test/-ext-/symbol/test_type.rb index fdee692fe4..2b0fbe5b79 100644 --- a/test/-ext-/symbol/test_type.rb +++ b/test/-ext-/symbol/test_type.rb @@ -134,5 +134,10 @@ module Test_Symbol Bug::Symbol.find(cx) } end + + def test_const_name_type + sym = "\xb5".force_encoding(Encoding::Windows_1253) + assert_not_operator Bug::Symbol, :const?, sym, sym.encode(Encoding::UTF_8) + end end end