-
Notifications
You must be signed in to change notification settings - Fork 21
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
feat: prevent special characters from url #1266
Closed
lauramargar
wants to merge
8
commits into
main
from
feature/EMP-1745-prevent-special-keys-that-come-from-url
Closed
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
79ce508
[EMP-1745]
lauramargar 4a42549
chore: another approach related to the pr comments
lauramargar 67a3d0a
Merge branch 'main' of https://github.com/empathyco/x into feature/EM…
lauramargar db1cd5f
chore: remove special keys from all params in URL
lauramargar f2c20b5
chore: add more cases to prevent html injection
lauramargar 8e9b26d
chore: fix replace options
lauramargar 461dd69
chore: pr comments
lauramargar eb64d7f
chore: new approach using sanitize util
lauramargar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
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.
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.
To be safe we should sanitize all values and not just the first one. The query only has one occurrence but potentially any parameter could be malicious.
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.
urlValue
is not onlyquery
param, all URL params are passing one by one.[0]
is necessary because urlValue is an array of only one element, the param that is being checked.For example, try to search for a query and select a filter, then write the special characters (
<>
) in the filter and in the query.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.
Sorry, I think I did not explain properly 😅 What I meant is that a url param can have more than one occurrence. Think about filters, you can select more than one filter at the same time. In that scenario you get an array with multiple entries like:
['categoryIds:12fad53d7', 'price:1600.0-2000.0']
so if you only pick the first element, you will fail to sanitize the other values.