[Enterprise Search] Prevent double encoding in enterprise_search_request_handler#79747
Merged
JasonStoltz merged 2 commits intoelastic:masterfrom Oct 7, 2020
Merged
Conversation
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`.
6 tasks
cee-chen
reviewed
Oct 6, 2020
x-pack/plugins/enterprise_search/server/lib/enterprise_search_request_handler.ts
Outdated
Show resolved
Hide resolved
cee-chen
reviewed
Oct 6, 2020
x-pack/plugins/enterprise_search/server/lib/enterprise_search_request_handler.test.ts
Outdated
Show resolved
Hide resolved
cee-chen
reviewed
Oct 6, 2020
x-pack/plugins/enterprise_search/server/lib/enterprise_search_request_handler.test.ts
Show resolved
Hide resolved
Co-authored-by: Constance <constancecchen@users.noreply.github.com>
cee-chen
approved these changes
Oct 6, 2020
Contributor
cee-chen
left a comment
There was a problem hiding this comment.
Woo, thanks for catching this Jason! 🎉
Contributor
💚 Build SucceededMetrics [docs]
To update your PR or re-run it, just comment with: |
Contributor
|
Friendly reminder: Looks like this PR hasn’t been backported yet. |
1 similar comment
Contributor
|
Friendly reminder: Looks like this PR hasn’t been backported yet. |
Contributor
|
Backporting on behalf of Jason since he's out most of this week |
Member
Author
|
Thank you @constancecchen |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
enterprise_search_request_handler was double encoding urls.
This is because
querystring.stringifywas already encoding, andwe were subsequentally calling
encodeURIon 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
encodeURIComponentoption for thestringifymethod, whichdefaults 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