Bug 405649 - help:/ handler loses fragments
Summary: help:/ handler loses fragments
Status: RESOLVED FIXED
Alias: None
Product: frameworks-kguiaddons
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: kdelibs bugs
URL:
Keywords:
: 426748 438205 (view as bug list)
Depends on:
Blocks:
 
Reported: 2019-03-19 14:31 UTC by Harald Sitter
Modified: 2021-06-27 18:28 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.84


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Harald Sitter 2019-03-19 14:31:17 UTC
Some of our our software (particularly KCMs) have documentation paths set including fragments.

e.g. kinfocenter's memory module has

X-DocPath=kinfocenter/index.html#kcm_memory

which expressed as an url will be 'help:/kinfocenter/index.html#kcm_memory'. The fragment is lost in UrlHandler::openHelp where it only picks up the path but not the fragment:

                const QUrl httpUrl(QStringLiteral("https://docs.kde.org/index.php?branch=stable5&language=")+QLocale().name()+QStringLiteral("&application=") +
                    QCoreApplication::applicationName() + QStringLiteral("&path=") + url.path());

Same probably for a potential query?
Also the path likely should be percent-encoded as otherwise it's unclear if the fragment applies to the master url or the path= url.

e.g. the run final url should be something like

https://docs.kde.org/index.php?branch=stable5&language=en_US&application=kinfocenter&path=%2Fkinfocenter%2Findex.html%23kcm_memory
Comment 1 Luigi Toscano 2021-06-07 21:46:10 UTC
*** Bug 438205 has been marked as a duplicate of this bug. ***
Comment 2 Ahmad Samir 2021-06-10 10:25:33 UTC
*** Bug 426748 has been marked as a duplicate of this bug. ***
Comment 3 Ahmad Samir 2021-06-10 10:54:36 UTC
https://invent.kde.org/frameworks/kguiaddons/-/merge_requests/18

This url help:/kinfocenter/index.html#kcm_memory doesn't really exist, I think it works because khelpcenter indexes all the html files in the handbook cache tarball (brief skimming of its code and looking at debug output, so not 100% sure), however when falling back to opening docs.kde.org, that indexing isn't an option, so the url has to be more precise.

Both of these work with khelpcenter:
help:/kinfocenter/index.html#kcm_memory
help:/kinfocenter/kcm_memory.html

I would argue that that second url is more accurate, as it points to an actual html file (whether it's one generated from the docbook cache.bz2 on the user's disk or it's the html file on docs.kde.org). That will probably require a mass change in .desktop files with X-DocPath.

The code in KGuiAddons should now handle both cases i.e. if it gets help:/foo/index.html#bar it'll use:
foo/bar.html

However if we get help:/okular/index.html#adding_digital_signatures that won't work (see bug 438205), that should be fixed with https://invent.kde.org/graphics/okular/-/merge_requests/441 which basically changes the url to:
help:/okular/signatures.html#adding_digital_signatures

and now the openHelp() method can handle it.
Comment 4 Ahmad Samir 2021-06-10 10:57:55 UTC
About percent encoding, since openHelp() interprets the url is weird ways, I am not sure percent encoding the url is needed, we process what we get if it's a #, then that is it :)
Comment 5 Harald Sitter 2021-06-10 11:21:43 UTC
(In reply to Ahmad Samir from comment #3)
> https://invent.kde.org/frameworks/kguiaddons/-/merge_requests/18
> 
> This url help:/kinfocenter/index.html#kcm_memory doesn't really exist, I
> think it works because khelpcenter indexes all the html files in the
> handbook cache tarball (brief skimming of its code and looking at debug
> output, so not 100% sure), however when falling back to opening
> docs.kde.org, that indexing isn't an option, so the url has to be more
> precise.
> 
> Both of these work with khelpcenter:
> help:/kinfocenter/index.html#kcm_memory
> help:/kinfocenter/kcm_memory.html
> 
> I would argue that that second url is more accurate, as it points to an
> actual html file (whether it's one generated from the docbook cache.bz2 on
> the user's disk or it's the html file on docs.kde.org). That will probably
> require a mass change in .desktop files with X-DocPath.
> 
> The code in KGuiAddons should now handle both cases i.e. if it gets
> help:/foo/index.html#bar it'll use:
> foo/bar.html

For the url thrown at the browser? This sounds wrong.

#foo is referring to an anchor on the page, not a page.

e.g.
https://docs.kde.org/stable5/en/kinfocenter/kinfocenter/module.html#aboutsystem

which is

<a name="aboutsystem"></a>

When the X-DocPath is `kinfocenter/module.html#aboutsystem` it actually really needs to open https://docs.kde.org/stable5/en/kinfocenter/kinfocenter/module.html#aboutsystem
Comment 6 Ahmad Samir 2021-06-10 11:24:23 UTC
I probably should have pointed that out, my example is only about "index.html", any other "foo.html" is kept.