-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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
src: fix ThrowInvalidURL call in PathToFileURL #57141
src: fix ThrowInvalidURL call in PathToFileURL #57141
Conversation
Replace `nullptr` with `std::nullopt` when calling `ThrowInvalidURL` in `PathToFileURL`. This ensures the function receives the correct argument type and aligns with the expected behavior.
Review requested:
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #57141 +/- ##
==========================================
+ Coverage 88.54% 89.03% +0.49%
==========================================
Files 665 665
Lines 193408 193408
Branches 36961 37278 +317
==========================================
+ Hits 171250 172205 +955
+ Misses 14795 13884 -911
+ Partials 7363 7319 -44
|
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.
should we also add a test?
Do we have a test with a malformed URL? |
I would say so. |
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 once the test case is added. Thanks!
Do you guys have any clues about how to test this? I tried to reach such a condition, but I couldn't. |
Adding a CC_TEST would be the fastest |
@anonrig Do you have any examples of how to test this? As this is my first contribution I'm a bit lost on how to write a CC_TEST. |
Let me elaborate on my comment above where I wrote "Do we have a test with a malformed URL?". Here is the code: Utf8Value input(isolate, args[0]);
auto input_str = input.ToStringView();
CHECK(!input_str.empty());
auto out =
ada::parse<ada::url_aggregator>(EncodePathChars(input_str, os), nullptr);
if (!out) {
return ThrowInvalidURL(realm->env(), input.ToStringView(), somethinghere);
} The question is whether we have a test that triggers the |
@juanarbol @anonrig @jazelly @geeksilva97 Would you object to this fix getting merged without a test. I think we have no test that would trigger this issue, but by reading the code, what I expect happens when the problematic code path is triggered... is that you get a hard crash. This is a confirmed bug, I think that there is no disagreement about that. The fix looks correct to all of us. I think we should not block the fix due to a lack of good test. |
No objection from my side. |
Landed in fd45383 |
Replace `nullptr` with `std::nullopt` when calling `ThrowInvalidURL` in `PathToFileURL`. This ensures the function receives the correct argument type and aligns with the expected behavior. PR-URL: #57141 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com> Reviewed-By: Daniel Lemire <daniel@lemire.me>
Fixes #57133.
Replaces
nullptr
withstd::nullopt
when callingThrowInvalidURL
inPathToFileURL
. This ensures the function receives the correct argument type and aligns with the expected behavior.PS: I'm not sure how to test this, any help would be appreciated.