Link to filenames with spaces in Bitbucket Markdown (BB-15884)

Issue #12194 resolved
Vince Varga created an issue

Let's say I have a and I'd like to create a link to a file that contains spaces in its name, file with I'd like to be able to jump to the file's source code.

 -- File with

After inspecting the element in the browser, I figured out what the href should be (changed it manually, then clicking on it brought me to the page I want to reach):

<a href="username/repository/src/c0mm1th4sH/">

Unfortunately I couldn't accomplish that. Some of the things I have tried so far:

[Link](File with
[Link](File\ with\
[Link]("File with")

It results in the following HTML in Bitbucket:

<a href="/username/repository/src/c0mm1th4sH/">
<a href="/username/repository/src/c0mm1th4sH/">
<a href="/username/repository/src/c0mm1th4sH/">
<a href="" title="File with">

You can play with the example repository I created.

Stack Overflow

See comment:

Appears to be a tremendous amount of variation in how implementations render (updated Waylan's link) those. However, your second example seems to work most consistently. If that doesn't work, then I would report it as a bug. – Waylan

Comments (9)

  1. Abhin Chhabra Account Deactivated

    Hi @Vince Varga,

    I tried using your example repository and it seems that we render the %20 based link as you would have expected. The link is rendered as a relative link, as requested, but the problem with that link is that the relative link is incorrect based on where you happen to be. So if you happen to be in the source view, the second link correctly takes you to the requested file. But if you happen to look at the readme from another view such as this or this, the link leads you to a non-existent page.

    If I understand your ticket regarding the spaces in filenames correctly, then I can close this ticket. I've opened an enhancement ticket requesting that the relative links always be placed relative to the source view regardless of where the readme is rendered.

  2. Mauro Ronchi

    Actually, I can confirm that the links are rendered wrong if spaces are in the file name.

    both File with and renders as /username/repository/src/c0mm1th4sH/ (note the %2520)

    the correct url should be /username/repository/src/c0mm1th4sH/ (with %20s). if I edit the url manually it works from any view.

    conversely, the first link to (without spaces) correctly works from any view

  3. Vince Varga reporter

    Hi Abhin Chhabra,
    Hi Mauro Ronchi,

    I don't know why you changed the status of this issue to resolved, because the issue is still there. I made everything possible to create an example repository where it's easy for the developers at Bitbucket to test how markdown links are treated and with these repos it's obvious to demonstrate the problem. I'd like to give you a clarification, in case you still misunderstood. I am not a native English speaker, so I understand it could be difficult to understand what I meant.

    You are right, that the links with %20 replacing the spaces work. It's not my issue, however. The issue was that there is no way (or at least nothing I could find, and I tried really hard, created the repo, asked on Stack Overflow, took a look at different markdown implementations) to write markdown that creates valid links to a file that contains spaces (I can't create a link []() that will "redirect" to another file containing spaces).

    In the repo after the bulletpoints, you see how the links are created and you can use the developer tool of your choice to see what's the HTML that is eventually rendered.

    Changing view didn't help. I opened the in source view, tried all the 8 of my desperate tries and none of them worked. I tried this view as well in Firefox and Chrome (not like it's likely it has anything to do with it, but if an employee of Bitbucket says, it works, I take the time and see if I am speaking nonsense). Also, the most important thing would have been to have links directly rendered onto the repo's page vargavince91/space-markdown, where the README is rendered by default, so there would have been no tricks involved.

    Thank you for your help

  4. Vince Varga reporter
    • changed status to open

    The issue I was facing is still present. An empoyee of Bitbucket closed the issue regardless. I tried to clarify the issue at hand and provide more information that might help to solve the issue.

  5. Abhin Chhabra Account Deactivated

    Hi @Vince Varga,

    I apologize for wrongfully closing this ticket. It turns out that I was viewing your example repo with some experimental code enabled that rendered the page differently for me. But after noticing that, I was able to turn it off and I can confirm that the bug is still present. Now that I can reproduce it, I should be able to fix it. I'll work on this bug this week and keep you updated on the progress.

    Thank you.

  6. Abhin Chhabra Account Deactivated

    The fix for this issue has been deployed. I have confirmed that the example repository provided by the reporter does act better now.

    The recommended way to link to files with spaces is to use the URL encoded version (with %20s).

  7. Log in to comment