Remove redundant root slash for absolute paths

Having an absolute path with two starting slashes can lead to issues
with browsers like Tor Browser and sandboxes like AppArmor.

The former defaults to https:// if two slashes are supplied. Even
though the code explicitly states file://, this can still happen on
systems like Linux, because the open functions eventually call gio,
which removes the file:// prefix before passing the URI as argument to a
program.

AppArmor rejects read access even if configuration allows access
(configured with one slash), so a contained browser like Firefox, which
defaults to file://, could not open the html files.

Since paths are already set to absolute paths through dataPath call,
this additional slash can be removed in open functions.
This commit is contained in:
Tobias Stoeckmann 2025-12-10 00:04:34 +01:00
parent 331a2de136
commit f1f2ea86eb

View file

@ -1195,12 +1195,12 @@ void MainWindow::openBugReportUrl()
void MainWindow::openGettingStartedGuide()
{
customOpenUrl(QString("file:///%1").arg(resources()->dataPath("docs/KeePassXC_GettingStarted.html")));
customOpenUrl(QString("file://%1").arg(resources()->dataPath("docs/KeePassXC_GettingStarted.html")));
}
void MainWindow::openUserGuide()
{
customOpenUrl(QString("file:///%1").arg(resources()->dataPath("docs/KeePassXC_UserGuide.html")));
customOpenUrl(QString("file://%1").arg(resources()->dataPath("docs/KeePassXC_UserGuide.html")));
}
void MainWindow::openOnlineHelp()
@ -1210,7 +1210,7 @@ void MainWindow::openOnlineHelp()
void MainWindow::openKeyboardShortcuts()
{
customOpenUrl(QString("file:///%1").arg(resources()->dataPath("docs/KeePassXC_KeyboardShortcuts.html")));
customOpenUrl(QString("file://%1").arg(resources()->dataPath("docs/KeePassXC_KeyboardShortcuts.html")));
}
void MainWindow::switchToDatabases()