From e9ff56937b4a37e50af1a28ee8c416b00489d7f6 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Tue, 28 Jul 2026 15:02:38 +0900 Subject: [PATCH] Scan bytes as unsigned char in the implicit type matcher MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The re2c scanner in implicit.c read bytes as signed char, so any byte >= 0x80 satisfied the end-of-token check (yych <= 0x00) and a UTF-8 string like "Noémie" matched the "No" boolean rule. https://github.com/ruby/syck/issues/22 Co-Authored-By: Claude Fable 5 --- ext/syck/implicit.c | 2 +- test/test_boolean.rb | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/ext/syck/implicit.c b/ext/syck/implicit.c index 6911e61..734f53f 100644 --- a/ext/syck/implicit.c +++ b/ext/syck/implicit.c @@ -11,7 +11,7 @@ #include "ruby/ruby.h" #include "syck.h" -#define YYCTYPE char +#define YYCTYPE unsigned char #define YYCURSOR cursor #define YYMARKER marker #define YYLIMIT limit diff --git a/test/test_boolean.rb b/test/test_boolean.rb index edaffa6..bde17ed 100644 --- a/test/test_boolean.rb +++ b/test/test_boolean.rb @@ -32,5 +32,17 @@ def test_n assert_equal "n", Syck.load("--- n") assert_equal "N", Syck.load("--- N") end + + ### + # https://github.com/ruby/syck/issues/22 + # A boolean-like prefix followed by a non-ASCII byte must not be + # matched as a boolean + def test_bool_prefix_with_non_ascii + assert_equal "Noémie", Syck.load("--- Noémie") + assert_equal ["Noémie"], Syck.load("--- [Noémie]") + assert_equal "Yeså", Syck.load("--- Yeså") + assert_equal "trueé", Syck.load("--- trueé") + assert_equal "nullé", Syck.load("--- nullé") + end end end