-
-
Notifications
You must be signed in to change notification settings - Fork 905
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
refactor: Gumbo.parse
and .fragment
now use keyword arguments
#3199
Conversation
38935d0
to
926b0b9
Compare
Hi @flavorjones, This looks pretty much exactly like what I had in mind. A few questions:
|
Here's a branch which incorporates #3201 as well as removes the |
I've been trying to gradually improve the naming on our C functions, in particular the ones that are ruby methods, so that stack traces are a bit more meaningful. I don't feel strongly about this convention, but I'm already using it in a lot of places (try
Maybe? I'll take another look. The intention of that function was to ease the migration to first-class keyword arguments in Ruby 2.7/3.0, so it's probably worth a second look here.
Yeah, I like that a lot. I'll pull your branch into this PR. |
**What problem is this PR intended to solve?** See discussion at #3199 cc @stevecheckoway (Recreation of #3204 with additional commits)
These methods are internal and not part of the public API, so this isn't considered a breaking change. We're changing them to be more extensible going forward.
bb8bc2b
to
0d2b635
Compare
and ensure coverage with and without the explicit encoding argument. Co-authored-by: Mike Dalessio <mike.dalessio@gmail.com>
0d2b635
to
b924b4b
Compare
@stevecheckoway OK, I think this is ready for a final 👀 if you have a minute. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
// Add one to the max tree depth to account for the HTML element. | ||
if (options.max_tree_depth < UINT_MAX) { options.max_tree_depth++; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch on the overflow here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was caught by the downstream integration test with the Sanitize gem.
And it turns out there's no good way for the compiler to warn us because we can't even use the -Wconversion
compiler flag against Ruby header files. I've opened a PR upstream to try to fix that: ruby/ruby#10843
b924b4b
to
e53ea29
Compare
What problem is this PR intended to solve?
Refactor
Gumbo.parse
andGumbo.fragment
to use keyword arguments for parse options (instead of positional arguments).These methods are internal and not part of the public API, so this isn't considered a breaking change. We're changing them to be more extensible going forward.
See comments at #3178 for context
This PR also
max_parse_errors
Have you included adequate test coverage?
It's a refactor, existing test coverage should be sufficient.
Does this change affect the behavior of either the C or the Java implementations?
No behavior changes, but the HTML5 parser is only available in CRuby.