Bug 129899 - hyperlink() not working
Summary: hyperlink() not working
Status: RESOLVED NOTABUG
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
6.4.0.1 rc
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-01-09 05:24 UTC by CSLam
Modified: 2020-01-10 16:58 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description CSLam 2020-01-09 05:24:05 UTC
File reference containing "#" will return error, although the file does exist.  This appears to surface since more recent LibreOffice updates, while it works in the past without any problem.

eg
hyperlink("./Test#File.doc","Error") will return error.
Comment 1 Mike Kaganski 2020-01-09 06:09:53 UTC
I don't think it's a bug. "#" has a special meaning in URLs, separating fragment [1]; so a relative url like "./Test#File.doc" means "open "Test" in current document's location, and navigate to "File.doc" fragment inside it". I suppose it's not what you want.

The correct way to do this is

  =HYPERLINK("./" & ENCODEURL("Test#File.doc"))

[1] https://tools.ietf.org/html/rfc3986#section-3.5

Closing NOTABUG; if you disagree and want to return back to UNCONFIRMED, please don't forget to describe your opinion in details. Thanks!
Comment 2 Mike Kaganski 2020-01-09 06:22:52 UTC
Oh, I could speak too fast. I tried to repro with Version: 6.4.0.1 (x64)
Build ID: 1b6477b31f0334bd8620a96f0aeeb449b587be9f
CPU threads: 12; OS: Windows 10.0 Build 18363; UI render: default; VCL: win; 
Locale: ru-RU (ru_RU); UI-Language: en-US
Calc: threaded

and I see that the formula from comment 0 in fact opens file with name "Test#File.doc" in current directory; while as I wrote in comment 1, it should open file "Test". Is that your problem? You didn't specify what "the file does exist" means - specifically, what is the name of "the file". Please clarify.
Comment 3 CSLam 2020-01-10 05:56:33 UTC
Appreciate your explanation, which appears to tell why Calc is performing in such a manner.  Yet, this is ony a technical explanation of the situation, but the issue remains unresolved.  LibreOffice is designed for the average people, I guess, who may not be technically inclined.  I am seeing some issues here :-

1. There was not such an issue in the past, and "#" embedded in URL had been working perfectly, until more recentely; I think trouble begins from version 6.4.  As such, at least in my case, there have been a good volume of spreadsheets already created with "#" embedded URL.  The change as introduced more recently is practically asking the public to revise everything, if they want not to see the error.

2. While appreciating the meaning of "#" in the technical world, this particular thing is a valid filename character.  In other words, there are indeed files in the world that bears "#", which is not meant for the said technical spearation.  A good example is "Receiveable Account #000-00000-000.ods".  I believe it is obvious that this file refers to a particular account, but not anything else.

3. I do not know if it is correct to say so, but the "#" character in the URL is inside quotes, not outside.  It looks strange why LibreOffice is not interpreting the entire piece as a single string, but doing some manipulation prior to relaying the information to somewhere.

Naturally, I still hope LibreOffice can be updated to return to the previous URL handling.

CSLam
Comment 4 Mike Kaganski 2020-01-10 07:05:10 UTC
(In reply to CSLam from comment #3)
> 2. While appreciating the meaning of "#" in the technical world, this
> particular thing is a valid filename character.  In other words, there are
> indeed files in the world that bears "#", which is not meant for the said
> technical spearation.  A good example is "Receiveable Account
> #000-00000-000.ods".  I believe it is obvious that this file refers to a
> particular account, but not anything else.

No. It is *not* obvious. "#" in URL is a *point in a document* (like an entry of Contents you may see on any Wikipedia page, which leads you to a heading inside this same page); it is not something "technical" - it's something without which you *cannot* say "Open document X and navigate to chapter Y". So proper use of # is essential when working with links - and no amount or reasoning that "average people" should be comfortable with it will change that fact. When using HYPERLINK spreadsheet function, user *must* learn URLs and their peculiarities - because those are not separable; and the very existence of ENCODEURL function is because of those complexities.

> 3. I do not know if it is correct to say so, but the "#" character in the
> URL is inside quotes, not outside.  It looks strange why LibreOffice is not
> interpreting the entire piece as a single string, but doing some
> manipulation prior to relaying the information to somewhere.

Quotes is Calc way to pass strings to functions; and entire URL, including the fragment will necessarily be inside quotes - it would be a syntax error if # and fragment were outside. So this argument is incorrect.

However, and having said all that, I repeat that for me, HYPERLINK works as *you* would expect (i.e., *wrong*) with LO 6.4.0.1 - so possibly you need to explain better what doesn't work for you, *with a sample file*.
Comment 5 CSLam 2020-01-10 11:22:36 UTC
Thank you for your response.

Simply, hyperlink() does not point to "Account #000-0000000-000.ods", but reports there is an error - file not exists.  From your explanation, it probably is looking for "Account ", and somewhere inside called "000-00000000-000.ods".  Of course, this is not the intention.  And the strangest thing to me, it has been working until recently - and it takes quite a while learning that the culprit is "#".

CSLam
Comment 6 CSLam 2020-01-10 11:27:09 UTC
Just thought of something, and tried it.

The said problematic URL works correctly in OpenOffice - same file, nothing changed.

CSLam
Comment 7 Mike Kaganski 2020-01-10 16:58:09 UTC
What I see - testing with a spreadsheet in the same directory with files "Account #000-0000000-000.ods":

1. Using relative reference: =HYPERLINK("Account #000-0000000-000.ods")
   This has never worked since introduction of relative hyperlinks in v.6.1.
2. Using absolute reference: =HYPERLINK("file:///c:/path/to/Account #000-0000000-000.ods")
   This used to work in pre-6.2; the behaviour changed with https://git.libreoffice.org/core/+/441f2d56d6f7d1d36ec515c03a54a789fa767958.
3. Testing the same URLs with MS Excel, it doesn't open these URLs - as it should; this confirms that opening them by LO previously was indeed a bug, and current behaviour is correct and consistent.

Closing NOTABUG.