Qt: use toLocalFile() instead of path() to check for existence.

path() incorrectly gives paths as /C:/Program Files/Wireshark/udpdump.html
under windows. The leading slash gives a wrong test on the file. Instead
toLocalFile() handles it correctly. isLocalFile() has been used to get if
we have a local file or a network URL. The reported bug occurred under Windows
only, but the change is compatible with Linux paths as well.

Accidentally when the test on the file was successful, nothing got called.
The routine has been reworked to open an existing local file.

Bug: 15592
Change-Id: Id6e3a91dfb4c9d20ae8cb0735eabab64caeff47f
Reviewed-on: https://code.wireshark.org/review/32772
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
This commit is contained in:
Dario Lombardo 2019-04-07 19:11:55 +02:00 committed by Alexis La Goutte
parent 96fa471542
commit 4dda4bac17
1 changed files with 9 additions and 13 deletions

View File

@ -402,24 +402,20 @@ void ExtcapOptionsDialog::on_buttonBox_helpRequested()
QUrl help_url(interface_help);
/* The help is not a local file, open it and exit */
if (help_url.scheme().compare("file") != 0) {
QDesktopServices::openUrl(help_url);
return;
}
/* The help information is a file url and has been provided as-is by the extcap.
Before attempting to open the it, check if it actually exists.
*/
QFileInfo help_file(help_url.path());
if ( !help_file.exists() )
{
QMessageBox::warning(this, tr("Extcap Help cannot be found"),
/* Check the existence for a local file */
if (help_url.isLocalFile()) {
QFileInfo help_file(help_url.toLocalFile());
if (!help_file.exists()) {
QMessageBox::warning(this, tr("Extcap Help cannot be found"),
QString(tr("The help for the extcap interface %1 cannot be found. Given file: %2"))
.arg(device->name).arg(help_url.path()),
QMessageBox::Ok);
return;
}
}
/* We have an actual url or an existing local file. Let's open it. */
QDesktopServices::openUrl(help_url);
}
bool ExtcapOptionsDialog::saveOptionToCaptureInfo()