diff options
| author | Kevin Newton <kddnewton@gmail.com> | 2024-03-26 14:54:50 -0400 |
|---|---|---|
| committer | Kevin Newton <kddnewton@gmail.com> | 2024-03-27 08:34:42 -0400 |
| commit | e4b210906564cb5e922e8331a6b3724624377fdb (patch) | |
| tree | 910d87a97bc42d6315c2581f4450e7b8d579e90d | |
| parent | 44b5c912daae6d4e6dba6e40f13a2840c144cfa8 (diff) | |
[PRISM] Fix ASCII-compatible check for eval encoding
| -rw-r--r-- | prism_compile.c | 7 | ||||
| -rw-r--r-- | test/.excludes-prism/TestEval.rb | 1 |
2 files changed, 5 insertions, 3 deletions
diff --git a/prism_compile.c b/prism_compile.c index d7eada1538..a5b1219d6c 100644 --- a/prism_compile.c +++ b/prism_compile.c @@ -8611,9 +8611,12 @@ pm_load_parse_file(pm_parse_result_t *result, VALUE filepath) VALUE pm_parse_string(pm_parse_result_t *result, VALUE source, VALUE filepath) { - pm_string_constant_init(&result->input, RSTRING_PTR(source), RSTRING_LEN(source)); - rb_encoding *encoding = rb_enc_get(source); + if (!rb_enc_asciicompat(encoding)) { + return rb_exc_new_cstr(rb_eArgError, "invalid source encoding"); + } + + pm_string_constant_init(&result->input, RSTRING_PTR(source), RSTRING_LEN(source)); pm_options_encoding_set(&result->options, rb_enc_name(encoding)); pm_options_filepath_set(&result->options, RSTRING_PTR(filepath)); diff --git a/test/.excludes-prism/TestEval.rb b/test/.excludes-prism/TestEval.rb index 83f3e38fc9..6cc6bdfb1d 100644 --- a/test/.excludes-prism/TestEval.rb +++ b/test/.excludes-prism/TestEval.rb @@ -1,2 +1 @@ -exclude(:test_eval_ascii_incompatible, "incorrect encoding") exclude(:test_file_encoding, "incorrect encoding") |
