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

[Enterprise Search] Prevent double encoding in enterprise_search_request_handler #79747

Merged
merged 2 commits into from
Oct 7, 2020

Conversation

JasonStoltz
Copy link
Member

@JasonStoltz JasonStoltz commented Oct 6, 2020

enterprise_search_request_handler was double encoding urls.

This is because querystring.stringify was already encoding, and
we were subsequentally calling encodeURI on the same url.

This resulted in something like "page[current]=2" to be converted
to "page%255Bcurrent%255D=2", rather than
"page%5Bcurrent%5D=2"; it was double encoded.

References: https://nodejs.org/api/querystring.html
See the encodeURIComponent option for the stringify method, which
defaults to escape.

Summary

Summarize your PR. If it involves visual changes include a screenshot or gif.

Checklist

Delete any items that are not applicable to this PR.

For maintainers

enterprise_search_request_handler was double encoding urls.

This is because `querystring.stringify` was already encoding, and
we were subsequentally calling `encodeURI` on the same url.

This resulted in something like "page[current]=2" to be converted
to "page%255Bcurrent%255D=2", rather than
"page%5Bcurrent%5D=2"; it was double encoded.

References: https://nodejs.org/api/querystring.html
See the `encodeURIComponent` option for the `stringify` method, which
defaults to `escape`.
@JasonStoltz JasonStoltz requested review from cee-chen and a team October 6, 2020 19:32
@JasonStoltz JasonStoltz added v7.11.0 release_note:skip Skip the PR/issue when compiling release notes labels Oct 6, 2020
Copy link
Contributor

@cee-chen cee-chen left a comment

Choose a reason for hiding this comment

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

Woo, thanks for catching this Jason! 🎉

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

✅ unchanged

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@JasonStoltz JasonStoltz merged commit 718702c into elastic:master Oct 7, 2020
@JasonStoltz JasonStoltz deleted the fix-double-encoding branch October 7, 2020 11:45
@kibanamachine kibanamachine added the backport missing Added to PRs automatically when the are determined to be missing a backport. label Oct 9, 2020
@kibanamachine
Copy link
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create backports run node scripts/backport --pr 79747 or prevent reminders by adding the backport:skip label.

1 similar comment
@kibanamachine
Copy link
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create backports run node scripts/backport --pr 79747 or prevent reminders by adding the backport:skip label.

@cee-chen
Copy link
Contributor

Backporting on behalf of Jason since he's out most of this week

cee-chen pushed a commit that referenced this pull request Oct 12, 2020
@kibanamachine kibanamachine removed the backport missing Added to PRs automatically when the are determined to be missing a backport. label Oct 12, 2020
@JasonStoltz
Copy link
Member Author

Thank you @constancecchen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release_note:skip Skip the PR/issue when compiling release notes v7.11.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants