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

netops: handle intact query parameters in service_suffix removal #5339

Merged
merged 1 commit into from Jan 10, 2020

Conversation

josharian
Copy link
Contributor

Some servers leave the query parameters intact in the
Location header when responding with a redirect.
The service_suffix removal check as written assumed
that the server removed them.
Handle both cases.

Along with PR #5325, this fixes #5321.

Please review skeptically; my C is extremely rusty.

Copy link
Member

@pks-t pks-t left a comment

Choose a reason for hiding this comment

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

I honestly find it very hard to reason about this, but this is no fault of yours. We do have tests in "tests/network/redirect.c" that are supposed to exercise this function. Would you feel up to the task of adding some tests in there that show what exact scenario you're fixing? Feel free to say "no" here and I'll try to come up with some tests myself based on your description.

src/netops.c Outdated Show resolved Hide resolved
Some servers leave the query parameters intact in the
Location header when responding with a redirect.
The service_suffix removal check as written assumed
that the server removed them.
Handle both cases.

Along with PR libgit2#5325, this fixes libgit2#5321.

There are two new tests. The first already passed;
the second previously failed.
@josharian
Copy link
Contributor Author

I honestly find it very hard to reason about this, but this is no fault of yours.

That's kind, but I'll take the fault. I've added more documentation in the code.

We do have tests in "tests/network/redirect.c" that are supposed to exercise this function.

Thanks for the pointer. I hadn't found those, only the tests against live servers. I've added two tests. The first already passed; the second previously failed.

Copy link
Member

@pks-t pks-t left a comment

Choose a reason for hiding this comment

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

Perfect, thanks a lot for your amendments! Tests look good to me and the new comments definitely help.


/* Check for a redirect without query parameters, like "/newloc/info/refs" */
Copy link
Member

Choose a reason for hiding this comment

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

Thanks a lot, these comments make things much clearer to me!

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.

/info/refs http request malformed when base remote path is /
2 participants