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

Strip markup from html_safe selected facet values in the html title. #3464

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

seanaery
Copy link
Contributor

@seanaery seanaery commented Dec 6, 2024

I'm not aware of cases outside of the blacklight_range_limit plugin that render markup in the selected value. However, there's a precedent for using strip_tags on the selected facet value in core in the ConstraintLayoutComponent here.

Solution in Action:
Screenshot 2024-12-06 at 8 23 27 AM

jrochkind
jrochkind previously approved these changes Dec 17, 2024
@jrochkind
Copy link
Member

I don't love how this isn't sticking to usual model of tracking whether a string is HTML or not.

Here we don't know if the string will be HTML, or possibly plain text (including non-html-safe things like angle-brackets!), but then strip_tags on it anyway. If it wasn't meant to be html and html-safe, then we may strip away things that were not meant to be stripped.

I'm not sure if there's a better solution though, this is getting convoluted.

In the specific example of the string coming from range limit, is it already html_safe?? Could strip_tags only if html_safe? that is normally a rails way of marking whether a string is a string literal or HTML code.

@seanaery
Copy link
Contributor Author

@jrochkind Very good call -- thank you so much for looking closely and catching that. Indeed, using strip_tags like this would unintentionally turn a selected value like Six > Five into Six > Five in the title, which we would not want.

Yes, the label coming from the BlacklightRangeLimit::FacetItemPresenter is html_safe, so I'll see if I can refine this a bit.

- E.g., span/data-attributes rendered for selected range facet values by blacklight_range_limit
- Does not affect typical values that are not marked html_safe
- Fixes #2707
- Fixes projectblacklight/blacklight_range_limit#189
@seanaery seanaery force-pushed the html-title-strip-tags branch from 7df9af1 to d1544a9 Compare December 18, 2024 14:52
@seanaery seanaery changed the title Strip markup from selected facet values in the html title. Strip markup from html_safe selected facet values in the html title. Dec 18, 2024
@seanaery
Copy link
Contributor Author

@jrochkind Thanks again for your helpful feedback on how to refine this. I have updated the PR so strip_tags would now only apply to html_safe values.

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.

span tag in html/head/title when range selected
2 participants