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

Require source code to be at most 16MiB #81

Merged
merged 1 commit into from
Oct 13, 2020

Conversation

peterzhu2118
Copy link
Member

Raise when source is larger than 16MiB in Liquid::Template#parse. This will let us use this assumption in liquid-c.

See #79.

lib/liquid/c.rb Outdated
alias_method :ruby_parse, :parse

def c_parse(source, options = {})
if source.bytesize > Liquid::Template::MAX_SOURCE_CODE_BYTES
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be simpler do this is on an existing parsing code path, rather than introducing another monkey patch. Also, we generally do the safety checks for C code in the C code itself, which avoids the ability for ruby code to trigger undefined behaviour. So I would do it in tokenizer_initialize_method after the existing source checks.

@peterzhu2118 peterzhu2118 force-pushed the pz-max-source-code-bytes branch from 880d132 to 9335dc3 Compare October 9, 2020 18:00
@peterzhu2118 peterzhu2118 merged commit 368792e into master Oct 13, 2020
@peterzhu2118 peterzhu2118 deleted the pz-max-source-code-bytes branch October 13, 2020 13:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants