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

3937 - Links clicked in read views replace current tab #4262

Merged

Conversation

WillNigel23
Copy link
Collaborator

No description provided.

@WillNigel23 WillNigel23 linked an issue Aug 6, 2024 that may be closed by this pull request
my_display_html.strip,
tags: SANITIZE_ALLOWED_TAGS,
attributes: SANITIZE_ALLOWED_ATTRIBUTES
).gsub('<br>','<br/>').gsub('<hr>','<hr/>')
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It seems the sanitize function is stripping 'target' attributes on hrefs.
We can deal with this by whitelisting href and target, but passing in attributes is restrictive rather than additive so I declared SANITIZE_ALLOWED_ATTRIBUTES above.

I may have missed some attributes there but I prioritized obvious ones and those that are explicitly used here in xml_to_html function.

NOTE:
Users will still have to add target="_blank" or "new" as done here:
https://www.fromthepage.com/nbwm/logbooks-and-journals/kwm-482/display/32946693

Let me know if this is okay

@@ -24,6 +26,11 @@
expect(xml_to_html(@xml_text, false, true)).to include("Faith<span class=\"line-break\"></span>fully")
end

it 'returns a <a> tag with preserved href and target attributes' do
expect(xml_to_html(@xml_text, true, true)).to include(@a_tag_with_attr)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

added specs to test new functionality

@benwbrum
Copy link
Owner

benwbrum commented Sep 6, 2024

This is tested and can be merged as soon as it passes spec tests.

@benwbrum benwbrum merged commit 1ea8347 into development Sep 14, 2024
3 checks passed
@benwbrum benwbrum deleted the 3937-links-clicked-in-read-views-replace-current-tab branch September 14, 2024 19:54
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.

links clicked in read views replace current tab
2 participants