gradio: Gradio sanitizing links; no longer able to open in new window
Describe the bug
Currently my chat bot returns verified sources with html links as seen below. It uses the target="_blank"> to open these links in a new tab. Gradio past the version that introduced marked now sanitizes this target parameter out of the processed link.
input:
f'<a href="{link}" class="source" rel="noopener noreferrer" target="_blank"> {name} | {score:.0%}</a>
output in published site:
f'<a href="{link}" class="source" rel="noopener noreferrer"> {name} | {score:.0%}</a>
Is there an existing issue for this?
- I have searched the existing issues
Reproduction
working on it
Screenshot
working on it
Logs
working on it
System Info
gradio>=3.29.1
Severity
blocking upgrade to latest gradio version
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 17 (4 by maintainers)
I’ll look into that @6DammK9! Thanks for raising this.
Just commenting, not going to re-open the issue.
target="_blank"doesn’t work when the hyperlink has the same domain with the gradio host.Therefore when you’re working on some on-prem solution under a static domain, pay attention to this situation. My case is just using nginx to make the exact same PDF file host available in 2 domains.
This work:
xxx.company.com/chatbot>yyy.company.com/filehost.pdfThis doesn’t work: This work:xxx.company.com/chatbot>xxx.company.com/filehost.pdfI created an issue here explaining my situation.
Thanks. I noticed that… pros and cons. Sadly, having the web page change and user losing the entire chat history when clicking on a link is is what I am trying to avoid
Heads up, that version leveraged marked’s html sanitization; it wasn’t the best and often parsed html as text.
We should make sure we add the correct
relattributes as well to prevent security issues:https://github.com/cure53/DOMPurify/issues/317#issuecomment-698800327
We should also add
noreferrerin addition tonoopener.Based on my testing, the last version when this worked was 3.31.0 (i checked checked each version from the latest and worked backwards)
I’ve been able to repro this in a test space here with 3.35.2. Might be a side effect of #3667. Looking into fixing this!