Skip to content

Commit

Permalink
[PRISM] Fix ASCII-compatible check for eval encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
kddnewton committed Mar 27, 2024
1 parent 44b5c91 commit e4b2109
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
7 changes: 5 additions & 2 deletions prism_compile.c
Expand Up @@ -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));
Expand Down
1 change: 0 additions & 1 deletion test/.excludes-prism/TestEval.rb
@@ -1,2 +1 @@
exclude(:test_eval_ascii_incompatible, "incorrect encoding")
exclude(:test_file_encoding, "incorrect encoding")

0 comments on commit e4b2109

Please sign in to comment.