Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limit max encodings to 256 and raise error #3434

Merged

Conversation

thomasmarshall
Copy link
Contributor

Part of #3039.

This limits the max number of encodings when calling rb_define_dummy_encoding and raise EncodingError as per Ruby issue 18949. Tests inspired by this from MRI.

@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Feb 2, 2024
@thomasmarshall thomasmarshall force-pushed the jose-thomas-encoding-max-size-error branch from 3126bf7 to 0da1996 Compare February 2, 2024 12:08
Copy link
Collaborator

@nirvdrum nirvdrum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great. I wonder if we exploit the max length now to simplify the handling of the encoding list, but it's okay to limit this PR to adding the new limit.

@@ -721,4 +721,25 @@
str.bytes.should == [0, 0x24]
end
end

describe "rb_define_dummy_encoding" do
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for writing new specs!

@thomasmarshall thomasmarshall force-pushed the jose-thomas-encoding-max-size-error branch 2 times, most recently from 298709f to e93e6b0 Compare February 2, 2024 16:35
@thomasmarshall thomasmarshall marked this pull request as ready for review February 2, 2024 17:04
Copy link
Member

@andrykonchin andrykonchin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

But it seems one way to create new encoding is missing - Encoding#replicate. It's implemented in org.truffleruby.core.encoding.EncodingNodes.EncodingReplicateNode.

@thomasmarshall thomasmarshall force-pushed the jose-thomas-encoding-max-size-error branch 3 times, most recently from 0e65921 to 8a405cd Compare February 5, 2024 19:15
@andrykonchin andrykonchin added the in-ci The PR is being tested in CI. Do not push new commits. label Feb 6, 2024
@andrykonchin
Copy link
Member

Could you please rebase on master to fix conflict in spec/tags/core/encoding/replicate_tags.txt?

@thomasmarshall thomasmarshall force-pushed the jose-thomas-encoding-max-size-error branch from 8a405cd to 7408c34 Compare February 9, 2024 14:31
@graalvmbot graalvmbot merged commit 7408c34 into oracle:master Feb 13, 2024
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in-ci The PR is being tested in CI. Do not push new commits. OCA Verified All contributors have signed the Oracle Contributor Agreement. shopify
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants