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

Fix username rendering bug #2122

Merged
merged 3 commits into from
Jul 12, 2017
Merged

Fix username rendering bug #2122

merged 3 commits into from
Jul 12, 2017

Conversation

ethantkoenig
Copy link
Member

@ethantkoenig ethantkoenig commented Jul 7, 2017

Fixes #1629.

Don't sanitize user's full names in the database. Since user.FullName and user.DisplayName() are strings, they are automatically already sanitized by the templating engine. If we sanitize the values stored in the database, users' full name end up being up sanitized twice.

I'm planning to add an integration test soon. Added an integration test

Copy link
Member

@lafriks lafriks left a comment

Choose a reason for hiding this comment

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

This needs migration to unsanitize already broken user full names

@lafriks
Copy link
Member

lafriks commented Jul 7, 2017

Integration test for this would be nice

@tboerger tboerger added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jul 7, 2017
@bkcsoft
Copy link
Member

bkcsoft commented Jul 7, 2017

@lafriks No migrations, AfterSet is ran on Read operations :)

@ethantkoenig
Copy link
Member Author

@bkcsoft True, but I also made changes to updateUser(..).

@lafriks It's not always possible to reconstruct an unsanitized string from a sanitized one. For instance, if a sanitized full name is "a & b", the unsanitized version could be "a & b" or "a & b".

Additionally, we don't currently have a function unsanitizing, and IMO writing one seems like more trouble than it would be worth. I'm guessing only a small number of actual users have been affected by this, and they can just changes their names manually.

@bkcsoft
Copy link
Member

bkcsoft commented Jul 7, 2017

@ethantkoenig if it's sanitized & would always be &, otherwise it would say & 😄

@ethantkoenig
Copy link
Member Author

ethantkoenig commented Jul 7, 2017

@bkcsoft Both markdown.Sanitize("&") and markdown.Sanitize("&") give me "&". So even though "&" would ideally be sanitized as "&", for our purposes we can't unsanitize without making assumptions (since full names were sanitized using markdown.Sanitize)

@lafriks
Copy link
Member

lafriks commented Jul 8, 2017

Even if & is sanitized as & I don't see how someone would have such symbols in full name so in all cases it can be changed to just &

@lafriks
Copy link
Member

lafriks commented Jul 8, 2017

For migration golangs built in html.UnescapeString could be used

@ethantkoenig
Copy link
Member Author

@lafriks Migration added

@lunny lunny added this to the 1.2.0 milestone Jul 10, 2017
@lunny lunny added the type/bug label Jul 10, 2017
@lafriks
Copy link
Member

lafriks commented Jul 12, 2017

LGTM

@tboerger tboerger added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Jul 12, 2017
@lunny
Copy link
Member

lunny commented Jul 12, 2017

LGTM

@tboerger tboerger added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Jul 12, 2017
@lafriks lafriks merged commit 858324c into go-gitea:master Jul 12, 2017
@ethantkoenig ethantkoenig deleted the fix/render branch July 19, 2017 02:14
@go-gitea go-gitea locked and limited conversation to collaborators Nov 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Characters like "&" in Organization Full Name are converted/displayed as html
6 participants