# Discourse encodes fragments of pasted URLs

**URL:** <https://meta.discourse.org/t/discourse-encodes-fragments-of-pasted-urls/137229>\
**Category:** Bug\
**Created:** [December 28, 2019, 12:29pm UTC](https://meta.discourse.org/t/discourse-encodes-fragments-of-pasted-urls/137229 "2019-12-28T12:29:54Z")\
**Posts on this page:** 7\
**Page:** 1

## AI-generated summary

The issue involves Discourse incorrectly encoding URL fragments (e.g., after `#`) when pasting links, turning `https://gitpod.io/#https://github.com/eclipse-theia/theia` into `https://gitpod.io/#https%3A%2F%2Fgithub.com%2Feclipse-theia%2Ftheia`. [svenefftinge](/t/-/137229/1) first reported this, noting it only affects oneboxed URLs. [codinghorror](/t/-/137229/2) tested and confirmed the behavior. [cvx](/t/-/137229/8) later noted the issue appears fixed in a pull request to the onebox gem, with tests added for the reported URL. However, [jankeromnes](/t/-/137229/9) reported the bug still occurs in Discourse `2.4.0.beta9` when using private messages, specifically with URLs like `https://gitpod.io/#snapshot/abcd-1234`, which become `https://gitpod.io/#snapshot%2Fabcd-1234`. [j.jaffeux](/t/-/137229/10) tested in a private message and confirmed it now works — suggesting the fix may have been included in `beta10` or later. The issue appears resolved in newer versions, but was persistent in at least `beta9`.

<div class="post-metadata">

**Author:** ![svenefftinge](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/svenefftinge/32/164986_2.png) [@svenefftinge](https://meta.discourse.org/u/svenefftinge)\
**Post date:** [December 28, 2019, 12:29pm UTC](https://meta.discourse.org/t/discourse-encodes-fragments-of-pasted-urls/137229/1 "2019-12-28T12:29:54Z")

</div>

Discourse encodes characters of fragments in pasted URLs.

E.g.  
`https://gitpod.io/#https://github.com/eclipse-theia/theia`  
becomes  
`https://gitpod.io/#https%3A%2F%2Fgithub.com%2Feclipse-theia%2Ftheia`

---

<div class="post-metadata">

**Author:** ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)\
**Post date:** [December 28, 2019, 6:08pm UTC](https://meta.discourse.org/t/discourse-encodes-fragments-of-pasted-urls/137229/2 "2019-12-28T18:08:39Z")

</div>

Let’s see

> **[Dashboard](https://gitpod.io/#https://github.com/eclipse-theia/theia)**

[Dashboard](https://gitpod.io/#https://github.com/eclipse-theia/theia)

So you are only referring to oneboxed urls?

---

<div class="post-metadata">

**Author:** ![svenefftinge](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/svenefftinge/32/164986_2.png) [@svenefftinge](https://meta.discourse.org/u/svenefftinge)\
**Post date:** [December 29, 2019, 8:22am UTC](https://meta.discourse.org/t/discourse-encodes-fragments-of-pasted-urls/137229/3 "2019-12-29T08:22:23Z")

</div>

Ah, there are two links. I didn’t noticed. So, yes, only the link in the box is broken.

---

<div class="post-metadata">

**Author:** ![cvx](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cvx/32/152146_2.png) [@cvx](https://meta.discourse.org/u/cvx)\
**Post date:** [December 30, 2019, 8:46am UTC](https://meta.discourse.org/t/discourse-encodes-fragments-of-pasted-urls/137229/8 "2019-12-30T08:46:33Z")

</div>

This appears to be fixed in [DEV: Replace custom uri\_encode logic with Addressable by cvx · Pull Request #420 · discourse/onebox · GitHub](https://github.com/discourse/onebox/pull/420)

I’ve added the reported URL to `#uri_encode` specs.

---

<div class="post-metadata">

**Author:** ![jankeromnes](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jankeromnes/32/117299_2.png) [@jankeromnes](https://meta.discourse.org/u/jankeromnes)\
**Post date:** [February 13, 2020, 11:21am UTC](https://meta.discourse.org/t/discourse-encodes-fragments-of-pasted-urls/137229/9 "2020-02-13T11:21:31Z")

</div>

Note: This still happens in Discourse version `2.4.0.beta9 (c15d702ae6)`:

In a Private Message, URLs like `https://gitpod.io/#snapshot/abcd-1234` still get wrongly converted to `https://gitpod.io/#snapshot%2Fabcd-1234`

I notice that Discourse `2.4.0.beta10` is out now – may try to upgrade and see if that helps.

---

<div class="post-metadata">

**Author:** ![j.jaffeux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j.jaffeux/32/60297_2.png) [@j.jaffeux](https://meta.discourse.org/u/j.jaffeux)\
**Post date:** [February 13, 2020, 12:05pm UTC](https://meta.discourse.org/t/discourse-encodes-fragments-of-pasted-urls/137229/10 "2020-02-13T12:05:59Z")

</div>

I just tried it in a PM and it worked.

---

<div class="post-metadata">

**Author:** ![j.jaffeux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j.jaffeux/32/60297_2.png) [@j.jaffeux](https://meta.discourse.org/u/j.jaffeux)\
**Post date:** [February 15, 2020, 12:06pm UTC](https://meta.discourse.org/t/discourse-encodes-fragments-of-pasted-urls/137229/11 "2020-02-15T12:06:07Z")

</div>

Closed on February 15, 2020, 12:06pm UTC

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.
