-
Notifications
You must be signed in to change notification settings - Fork 37
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
Prevent NPE for relative fragment w/ base != null. #28
Conversation
@sideshowbarker Could you add a test case for this? You can try adding it to |
@smola There's sorta already a test case for it at https://github.com/smola/galimatias/blob/master/src/test/resources/data/urltestdata_whatwg.txt#L32 That's the simplest case that will reproduce it -- just the string "#" (relative URL with no path part and no query part but with an (empty) fragment part). I say that's only "sorta" the right test case because it will only trigger that NPE is you're parsing a string when the base URL is null. But your test harness runs all its test cases with a base URL of "http://example.org/foo/bar" (because that's what that test data assumes). So as far as I can see, the current test harness is never going to be able exercise that code path unless you introduce some testing for the case when base URL set to null (in which case of course all the relative-URL cases should just completely fail -- maybe with a "No base URL set." message). By the way, if the base URL is null, parsing any string with a fragment part but no query part will trigger that NPE. So anything in lines 32-35 of https://github.com/smola/galimatias/blob/master/src/test/resources/data/urltestdata_whatwg.txt or "#foo" or whatever. You can test this right now with the CLI by just doing this:
That will trigger the NPE in the current code, because the CLI currently just always tests with the base URL set to null. (So, unlike the test harness, the CLI does exercise the problem code.) |
Actually, looking at this further, it seems to me you'll hit this NPE even when the base URL is not null, if the following are both true:
|
Added a test to |
Prevent NPE for relative fragment w/ base != null.
No description provided.