Adding an external link to the Reason field (badge) fails silently

AI-generated summary

A bug was reported where adding an external link to the Reason field (badge) fails silently. dax provided a reproduction of the issue and suggested that the admin should be warned that the URL is invalid and an error should be thrown. saurabhp confirmed the issue and asked if throwing an error on external links was the desired behavior. After confirmation, saurabhp created a pull request (PR) to fix the issue, which was later merged by zogstrip. The fix will only allow internal links to posts and topics, and will throw an error on external links and plain text.

Repro on Meta:

  1. go to user admin page
  2. click on Edit badges
  3. assign a badge adding an external URL as Reason
  4. click Grant
  5. the badge is assigned, the Reason field remains empty

The admin should be warned that the URL is invalid (is not an internal URL) and clicking on Grant must produce the error Sorry, an error has occurred (btw a specific error is always better to identify where you are wrong).

4 Likes

Hi,

I can confirm this is the case when using external link. Do we want to throw error on external links? If yes, I can try to work on it.

Thanks

1 Like

Yes, because no error is shown when you click on Grant, so the administrators do not understand that they are wrong to insert the link.

Hi @dax ,
I have created PR for the same. I just wanted to confirm only links have to be allowed in reason, right? Plain text is also not valid, right?

https://github.com/discourse/discourse/pull/6690

Thanks

3 Likes

The only valid links are internal links to posts and topics, so no plain text.
Thanks, our engineers will review the PR soon.

2 Likes

PR has now been merged :ok_hand:

5 Likes