Link to a UNC path

Hello

I use Discourse as a Intranet Forum.
Now I try to make a Hyperlink to a file on a servershare (\\server.domain.local\share\file.txt).

When I create a link to a UNC path, it appears, but it does not work. When I click on the link nothing happens.

Thats the code I try in Discourse:
[My File] (file://///server.domain.local/share/file.txt)

Is there a way to create a Hyperlink to a UNC Path? Or is it generally not supported?

Have you added “file” to the allowed href schemes site setting?

6 Likes

Hi David

That does the trick :grinning::thumbsup:

Thank you!

3 Likes

It looks like the updated markdown renderer won’t convert file:// paths properly ( discourse 1.9.5 )

Hello,
I have added file to “allowed href schemes” but when I create a hyperlink using a file:// url, Discourse will post it with https instead of file.
Then when changing the https back to “file” it’s still opening a https link when clicking on it.

Is the “file” scheme supported in Discourse(I’m in v2.2.0.beta2 +5)?
br

@jomaxro can you verify we didn’t regress on href scheme support?

Can confirm that we did not regress completely, adding ftp or steam works. I cannot get file to work, however, though that could just mean I’m doing something wrong. Never used the file href scheme before.

3 Likes

Why are there an unusual number of forward slashes in there? Shouldn’t it be the same pattern for all schemes?

3 Likes

No clue. As mentioned, I’ve never seen the file href before. I used 3 for my screenshot as that’s what I saw over on SO: html - href="file://" doesn't work - Stack Overflow. In any case, I tried 1 (just in case), 2 (normal), 3 (SO answer), 4, & 5 (example in OP) slashes, none worked.

Is there any update on this issue? I run in the same problem using latest version. File is not working as expected.

Hi, I’m trying to use local links to PDF documents on local shared network device. I run Discourse locally as a documentation tool. I have tried to add “file” in the href settings, but cannot get a working local link. Is there any way around this? Is this broken or am I doing it wrong?

We should check this again @jomaxro

Updated my sandbox to 2.3.0.beta1, still not able to get file to work. Re-confirmed other custom href schemes do still work.

1 Like

It’s weird… <a href="file://myfile">link</a> works, but [link](file://myfile) does not. But both options work for other custom schemes as @jomaxro said :thinking:

Maybe something in the commonmark link internals is stripping out file:// specifically. A quick search doesn’t reveal anything obvious in the discourse codebase.

@user2 the workaround for now is to use the HTML syntax for your link

<a href="file://myfile">link</a>

Edit: even with that, we still have an issue with file:// protocols. It is very common for file paths to start with a / (signifying the root of the filesystem), so the link looks like file:///myfile. Our sanitizer doesn’t like the three slashes at the beginning, and treats the link as invalid.

6 Likes

Does this only apply for *NIX paths?

file://C:/file.f
file:///var/file.f

Opened a file in browser and I see file:///K:/file...., same on windows. But <a href="file://myfile">link</a> does not work either. Maybe it works on *nix based system but not on windows paths?

This

<a href="file://C:/test.log">test</a>

Gives

domain.tld/clicks/track?url=file%3A%2F%2FC%3A%2Ftest.log&amp;post_id=1103&amp;topic_id=345 ERR_UNSAFE_REDIRECT

Any news on this? :worried:

I’m still banging my head against the wall here.
Anyone got a clue of how to fix this? :confused:

Since Chrome 76 (July 2019), it looks like file:// links are now totally blocked: Restrictions on File Urls – text/plain

So, I don’t think there’s anything Discourse can do about this - it’s a browser security restriction.

3 Likes

This topic was automatically closed after 10 days. New replies are no longer allowed.