Change how tags are stripped for #2939 #2994
Merged
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.
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&
).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 ofstrip_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 useLoofah
as well (if it applies).