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

Change how tags are stripped for #2939 #2994

Merged
merged 1 commit into from
Feb 16, 2022

Conversation

sylvieed
Copy link
Collaborator

@sylvieed sylvieed commented Feb 9, 2022

Resolves #2939

The problem

Previously, HTML entities like ampersands in collection descriptions in the Find a Project page were incorrectly escaped (i.e & is shown instead of &).

escaped html

However, the ampersands show up as expected (&) on the Collection overview page and owner dashboard. The difference is that on the Find a Project page, strip_tags is called on the description, which is escaping special characters.

The solution

To change this behavior, we use Loofah.fragment(desc).text(encode_special_chars: false) instead of strip_tags(desc), which does the same thing (removes HTML tags) without escaping special characters (here's the documentation).

strip_tags is in three places in the Find a Project page, so they are all changed to use Loofah instead.

Further Problems

strip_tags is still used in other places in the code, and if what it's displaying has any HTML entities, they will not be shown correctly. We should change these to use Loofah as well (if it applies).

@sylvieed sylvieed changed the title change how tags are stripped for #2939 Change how tags are stripped for #2939 Feb 9, 2022
@sylvieed sylvieed linked an issue Feb 9, 2022 that may be closed by this pull request
@coveralls
Copy link

Coverage Status

Coverage remained the same at 79.939% when pulling 1a83b07 on 2939-ampersands-not-escaped into 219c85e on development.

Copy link
Owner

@benwbrum benwbrum left a comment

Choose a reason for hiding this comment

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

Looks good!

@benwbrum benwbrum merged commit 3468dd7 into development Feb 16, 2022
@benwbrum benwbrum deleted the 2939-ampersands-not-escaped branch February 16, 2022 21:49
sylvieed pushed a commit that referenced this pull request Jul 14, 2022
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.

ampersands in find a project page not escaped
3 participants