Links in custom badge descriptions don't work in badge directory

AI-generated summary

Links in Custom Badge Descriptions Don’t Work in Badge Directory

A bug has been reported where links in custom badge descriptions on the badge directory page do not work as expected. tobiaseigen first reported the issue, noting that when a link is clicked, it redirects to the badge page instead of the intended destination. The issue only occurs when logged in and does not affect default badges.

tobiaseigen and downey were initially unable to reproduce the issue, but after further investigation, downey was able to replicate it on their site, finding that the issue only occurs for badges with external links (including a full hostname and protocol).

The issue was caused by nesting A tags, which is not allowed according to the HTML5 spec. sam fixed the bug by committing a change to the Discourse codebase. The fix is available in the latest version of Discourse.

Sorry for being the niggler on the newly implemented badge directory - looks really great and I very much appreciate the improvement. Thank you! :heart_eyes:

One small issue remaining is that if you create a custom badge description (as of today, there is long description and short description available to be edited - thanks!) and include linked text, it just links straight to the badge and not to the actual link destination. This problem is not exhibited for default badges like guidelines and I’m not able to replicate it here on meta.

But on my site, try clicking on the “Read the FAQ” badge and you’ll see what happens. Once there on the Read FAQ badge page, you can click again on the link and it takes you to the actual FAQ. I only have the description field filled out, not the long description field.

Just updated to latest and am at v1.5.0.beta13b +155.

1 Mi Piace

Ah - this problem only shows up on my site if I’m logged in. When visiting https://community.namati.org/badges in incognito mode, I am able to click through to the FAQ on my site.

I noticed this when checking out OpenMRS Talk. @downey can you confirm this?

I’m not able to reproduce this on my site regardless of my signed-in state … :confused:

I was able to click through to the destination page behind the link both from the badge directory page, and the individual badge page, both for stock badges and custom ones.

3 Mi Piace

Thanks for letting me know - that’s weird.

Not really a big deal - I can remove the link from the directory for the time being now that there’s a long description field for the badge page itself.

Also unable to reproduce on my local instance, do you have any plugins or customisations in play?

It looks to be a custom badge. i.e Read FAQ

Did you paste the link in yourself?

https://community.namati.org/t/faq-common-questions-about-the-network-platform/1467?u=tobiaseigen

Yes, I made a custom badge on local.

I just did a bunch of testing - disabled all my plugins and custom styling - and continue to get the same issue.

I also just tested another site I run and it’s not working there either.

Here’s the badges page where the link to “Kabissa Directory” should work but does not. The link takes you to the badge page instead of to the link. https://forum.kabissa.org/badges

Here’s a screenshot of the HTML I used for the description.

(yes, the main Kabissa website is down right now - working on that)

OK, I can reproduce it on my site, but only for badges that have an external link (including a full hostname and protocol), vs. an internal (relative) link.

3 Mi Piace

Thanks, we were being very naughty :rolling_eyes: and nesting A tags. (which is very not allowed according to the HTML/5 spec)

I fixed this per:

https://github.com/discourse/discourse/commit/6bb97dcabba0c80c33f89ae40f133b80f7ede55e

6 Mi Piace