Author Topic: Issue with file:// link in comment  (Read 1977 times)

LBCEi

  • Senior Community Member
  • Posts: 261
  • Hero Points: 21
Issue with file:// link in comment
« on: February 11, 2021, 04:59:55 PM »
I'm seeing a strange behavior with a file:// link in a comment in a C/C++ source file (.c).

When I ctrl-click to open the link, I get a Windows network error dialog (see attached) which shows a truncated filename.  The real filename is about 32 characters longer.  Initially I thought that it was a character count issue but if I just hit Cancel in the error dialog (or Diagnose, for that matter), the file opens in spite of the error.  In this case, it is an html file and it opens up in Chrome just fine.  In case it matters, the entire link, including quotes "file://.......html" is 172 characters long and has lots of spaces in the path as well as in the filename.  The file is on a network drive with NTFS file system.

Any thoughts?

This is with 25.0.1.0, no hotfixes, on Windows 10.  25.0.0.9, hotfix 5 does the same thing.

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6823
  • Hero Points: 526
Re: Issue with file:// link in comment
« Reply #1 on: February 11, 2021, 06:06:24 PM »
Links with spaces are not supported. Sounds like your link has spaces in it. You should notice that the underline does not span the entire link. When that happens, the link definitely won't work.

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6823
  • Hero Points: 526
Re: Issue with file:// link in comment
« Reply #2 on: February 11, 2021, 11:01:03 PM »
URLs with spaces will work if you use %20

Code: [Select]
file:///a%20b/test.html

LBCEi

  • Senior Community Member
  • Posts: 261
  • Hero Points: 21
Re: Issue with file:// link in comment
« Reply #3 on: February 13, 2021, 12:38:35 AM »
I will try replacing the spaces with %20, but it still seems strange that the link opens properly after the error dialog is dismissed.  If it is really an error, why does the desired action occur successfully in spite of the "error"? I have the entire link (including the file:// part) surrounded with double quotes (which is what you normally do to avoid issues with spaces in path/file names in Windows).  Also, why did the error dialog show only a truncated path/filename?

I realize that this is probably more an issue with Windows than SE itself.  Still, any insight that you have would be appreciated.

In your first response, Clark, you show three / characters after "file:".  Is that a typo, or is that the desired way to define a file link?

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6823
  • Hero Points: 526
Re: Issue with file:// link in comment
« Reply #4 on: February 13, 2021, 01:04:32 AM »
I link with a real space should not work at all. I can only guess there’s something weird going on which makes it look like it worked. The link is being cut short for sure.

When there are three slashes the first slash just specifies the root directory. Not sure if that’s needed. I never tested using just two slashes.

LBCEi

  • Senior Community Member
  • Posts: 261
  • Hero Points: 21
Re: Issue with file:// link in comment
« Reply #5 on: February 16, 2021, 01:34:04 AM »
I tried replacing the spaces with %20 and that broke it completely.  It opened my Documents folder in explorer instead of opening the actual file in Chrome after cancelling the error dialog.  I'm pretty sure I've successfully used file:// links with spaces before as long as I enclosed the entire link in double quotes (from before file to the end). 

Note that enclosing the entire link in double quotes does show the entire link underlined in the editor window.
« Last Edit: February 16, 2021, 02:05:04 AM by LBCEi »

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6823
  • Hero Points: 526
Re: Issue with file:// link in comment
« Reply #6 on: February 16, 2021, 10:58:30 PM »
Double quotes also works for me.

Both of these work for me:

Code: [Select]
"file:///a b/junk.html"
file:///a%20b/junk.html

SlickEdit does special case a file URL as follows. SlickEdit converts it to an actual filename and then uses ShellExecute to run it. This lets Windows do whatever it wants with the filename. For me, this opens the HTML file in my default browser.

This is similar to Windows+R and typing the filename (/a b/junk.html). SlickEdit seems to leave the forward slashes alone.
« Last Edit: February 16, 2021, 11:30:04 PM by Clark »

LBCEi

  • Senior Community Member
  • Posts: 261
  • Hero Points: 21
Re: Issue with file:// link in comment
« Reply #7 on: February 17, 2021, 01:58:30 AM »
As I said in my original post, the link does open (when written with spaces instead of %20 and enclosed in double quotes), but only after presenting an error dialog.  The error dialog is what annoys me.

Maybe I should try using the %20 replacement and removing the double quotes?

Also, SE is kind of finicky about actually trying to open the link rather than adding an additional cursor with Ctrl-Click.

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6823
  • Hero Points: 526
Re: Issue with file:// link in comment
« Reply #8 on: February 17, 2021, 02:27:01 AM »
What happens if you try this

Windows+R and type a file name like:

/a b/file-that-exists.html

Use a file name that exists. Use forward slashes to emulate what SlickEdit is doing for this.

LBCEi

  • Senior Community Member
  • Posts: 261
  • Hero Points: 21
Re: Issue with file:// link in comment
« Reply #9 on: February 19, 2021, 03:33:46 PM »
If I paste the file path that was causing the error dialog into the Run (Windows+R) dialog with double quotes it opens the file in my browser immediately with no error dialog.  I just copied the link, pasted it into the run dialog and deleted 'file://'.  It also worked fine if I pasted the entire link including 'file://'.

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6823
  • Hero Points: 526
Re: Issue with file:// link in comment
« Reply #10 on: February 19, 2021, 05:51:11 PM »
I've been testing a local file URL which has a space in it ("file:///a b/junk.html"). Does a local file URL with a space in it work for you?

What does your remote file URL look like?

Does your remote file URL have a drive letter in it?

I tried this remote URL with a space in it and it worked for me:

file://///file01/public/clark/a%20b.html


LBCEi

  • Senior Community Member
  • Posts: 261
  • Hero Points: 21
Re: Issue with file:// link in comment
« Reply #11 on: February 20, 2021, 12:44:08 AM »
The URL has (as I mentioned in my original post) lots of spaces in the path and the filename.  I have other links with spaces in my projects that work just fine (as long as I surround the entire link with double quotes), which is to be expected. 

When you refer to a "local file" do you mean one that is located on the same drive as SE (i.e., the C: drive)?

I don't ever link to files on the C: drive because the reference data that I am linking to is on a shared network drive and I want the links to work for everyone that works on the code.  I pretty much always link to a network drive (H:) using "file://H:/...".

I haven't tried using the network path instead of the drive letter.

Again, I have a lot of links in other source files that point to the same network folder (still using the 'file://H:/...' format) and this is the only one, so far, that causes the error dialog before opening the document). 

Your last example seems to have a huge amount of slashes after 'file:'.  What are you doing there?

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6823
  • Hero Points: 526
Re: Issue with file:// link in comment
« Reply #12 on: February 20, 2021, 04:58:31 AM »
I just kept adding slashes until it worked ;D

Thanks for the detailed explanation. I’ll try testing with a remote drive with a long path with lots of spaces. Wish me luck. I have no idea what’s so special about this URL.

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6823
  • Hero Points: 526
Re: Issue with file:// link in comment
« Reply #13 on: February 20, 2021, 06:11:01 PM »
No luck. I tried some very long paths with tons of spaces on a networked drive and it always works.

Maybe you could try creating small test files in shorter substrings of your long path.

If your path is:

file://h:/path1/path2/path3/path4/file.html

See if something shorter like this works:

file://h:/path1/path2/path3/junk.html

And keep shortening the path until it works.

Maybe just maybe we will get something out of this. There could be some weird permissions problem with one of the directories.
« Last Edit: February 20, 2021, 11:40:29 PM by Clark »

Graeme

  • Senior Community Member
  • Posts: 2793
  • Hero Points: 347
Re: Issue with file:// link in comment
« Reply #14 on: February 20, 2021, 09:11:56 PM »
I'm seeing a strange behavior with a file:// link in a comment in a C/C++ source file (.c).

When I ctrl-click to open the link, I get a Windows network error dialog (see attached) which shows a truncated filename.  The real filename is about 32 characters longer.  Initially I thought that it was a character count issue but if I just hit Cancel in the error dialog (or Diagnose, for that matter), the file opens in spite of the error.  In this case, it is an html file and it opens up in Chrome just fine.  In case it matters, the entire link, including quotes "file://.......html" is 172 characters long and has lots of spaces in the path as well as in the filename.  The file is on a network drive with NTFS file system.

Any thoughts?

This is with 25.0.1.0, no hotfixes, on Windows 10.  25.0.0.9, hotfix 5 does the same thing.

Does the string that the windows network error dialog shows have any spaces in it  - i.e. are all the spaces in the 32 character part that isn't shown or are there some before there.  If you turn on "show special characters" (view -> special characters) in slick, are there any special characters in the string?