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

models: user affiliations schema disallow html attrs #459

Closed

Conversation

zzacharo
Copy link
Member

❤️ Thank you for your contribution!

Description

Please describe briefly your pull request.

Checklist

Ticks in all boxes and 🟢 on all GitHub actions status checks are required to merge:

Third-party code

If you've added third-party code (copy/pasted or new dependencies), please reach out to an architect.

Reminder

By using GitHub, you have already agreed to the GitHub’s Terms of Service including that:

  1. You license your contribution under the same terms as the current repository’s license.
  2. You agree that you have the right to license your contribution under the current repository’s license.

@zzacharo zzacharo force-pushed the fix-user-aff-schema branch 2 times, most recently from cd73eb5 to a54a2d4 Compare September 18, 2023 08:10
except ValidationError as error:
raise ValueError(f"Validation failed: {error}")
return data
Copy link
Contributor

Choose a reason for hiding this comment

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

is it needed? the code should probably not reach here

Copy link
Member Author

Choose a reason for hiding this comment

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

if schema is None it acts as a normal dict...

Copy link
Contributor

Choose a reason for hiding this comment

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

in this case, minor for readability:

Suggested change
return data
def _validate(self, data):
"""Validate the data with the dictionary's schema and return the valid value."""
if self._schema is None:
return data
try:
# without schema, we basically revert to a normal dictionary
# with more overhead
return self._schema.load(data)
except ValidationError as error:
raise ValueError(f"Validation failed: {error}")

@@ -43,7 +44,8 @@ class UserProfileSchema(Schema):
"""The default user profile schema."""

full_name = fields.String()
affiliations = fields.String()
Copy link
Member

Choose a reason for hiding this comment

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

This is not correct. We use sanitised HTML when we want to store and output HTML, and string when we just want text.

@zzacharo
Copy link
Member Author

closing

@zzacharo zzacharo closed this Sep 18, 2023
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.

3 participants