-
Notifications
You must be signed in to change notification settings - Fork 192
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
Fixes #1973 - Adds normalization of metadata values. #1974
Conversation
@@ -154,6 +159,22 @@ def normalize_url(url): | |||
return url | |||
|
|||
|
|||
def normalize_metadata(metadata_value): | |||
"""Normalize the metadata received from the form.""" | |||
# Removing closing comments. |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
and the full test suite is still running.
I didn't run the functional tests though. Maybe to double check before. |
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.
Looks good, just one question about normalize_metadata
('blue sky ', 'blue sky'), | ||
('bad_bird <script>', ''), | ||
('bad_bird <script-->>', ''), | ||
('a' * 300, ''), |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
return None | ||
if '-->' in metadata_value: | ||
metadata_value = metadata_value.replace('-->', '') | ||
metadata_value = normalize_metadata(metadata_value) |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
metadata_value = metadata_value.replace('-->', '') | ||
metadata_value = normalize_metadata(metadata_value) | ||
# Let's avoid html tags in | ||
if ('<' or '>') in metadata_value and '-->' not in metadata_value: |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
# Let's avoid html tags in | ||
if ('<' or '>') in metadata_value and '-->' not in metadata_value: | ||
metadata_value = '' | ||
if len(metadata_value) > 200: |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
Looks good, thanks @karlcow. |
Following discussions in #1971, the goal of this pull request is to sanitize a bit. This is not perfect but should remove some of the issue. It goes on the side of safe play. For example if it detects there is
>
or<
it just sends back an empty string instead of trying to clean up.