glanceapp / glance

A self-hosted dashboard that puts all your feeds in one place
GNU Affero General Public License v3.0
8.56k stars 297 forks source link

Parenthesis in rss urls being escaped #219

Open Taffaz opened 2 months ago

Taffaz commented 2 months ago

A rather niche issue that is affecting me. I've created an API that converts the output from https://boardgamegeek.com/xmlapi2/hot?boardgame into an RSS feed that can be read using the RSS widget. However, if you look in the link the urls have parenthesis in them which get escaped. When I look at my glance homepage the image urls have %28%29 in place of ().

Is this something I can fix with a setting?

I'm fairly sure it's not an issue on my end as all my debugging indicates the () are being sent correctly and the escaping to %28%29 is happening on the glance server.

svilenmarkov commented 2 months ago

Unfortunately there is no setting to prevent this behavior. Go's html/template automatically escapes parentheses regardless of the type of the value, be it template.HTML, template.URL or template.HTMLAttr. There is an issue regarding this over at Go's repository (https://github.com/golang/go/issues/63586#issuecomment-2135979908) and I think I agree with rsc, it's up to the server to decode those characters properly.

The only way I can think of to overcome this from within Glance is to extract the entire <img> tag into a template.HTML and pass that to the template which should avoid the escaping, though it's kinda hacky and would require me to rewrite a bunch of stuff because images have different classes depending on the style of the widget. Happy to hear any other ideas if someone has a simpler solution.

Upon further research, this appears to be an old issue with thumbor, which is what boardgamegeek.com is using to serve its thumbnails.

Taffaz commented 2 months ago

Thanks for looking into it and providing more information. As a result I've redesigned to use the extension module to provide the html directly rather than relying on the RSS module and that works perfectly.