diff options
author | kh1 <qt-info@nokia.com> | 2011-05-16 13:31:48 +0200 |
---|---|---|
committer | kh1 <qt-info@nokia.com> | 2011-05-16 13:31:48 +0200 |
commit | f075d1ba95185328038ed5e877f8cac83d01e012 (patch) | |
tree | ec437762dee65b985f03a0ad013d07ff5d663f58 /installerbuilder/installerbase/installerbasecommons.cpp | |
parent | f2821573b18d7786d02aa8803bcdefa278e6c388 (diff) | |
parent | a54714b6cefc46e5952cbc9eb13d7264c2acbfd5 (diff) |
Merge branch 'master' into refactor
Conflicts:
installerbuilder/installerbase/installerbasecommons.cpp
Diffstat (limited to 'installerbuilder/installerbase/installerbasecommons.cpp')
-rw-r--r-- | installerbuilder/installerbase/installerbasecommons.cpp | 39 |
1 files changed, 30 insertions, 9 deletions
diff --git a/installerbuilder/installerbase/installerbasecommons.cpp b/installerbuilder/installerbase/installerbasecommons.cpp index 1d7707558..e43a3e120 100644 --- a/installerbuilder/installerbase/installerbasecommons.cpp +++ b/installerbuilder/installerbase/installerbasecommons.cpp @@ -235,17 +235,39 @@ bool TargetDirectoryPageImpl::validatePage() return false; } - QString remove = installer()->value(QLatin1String("RemoveTargetDir")); + const QDir dir(targetDir()); + if (dir.isRelative()) { + MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(), + QLatin1String("forbiddenTargetDirectory"), tr("Error"), + tr("The install directory cannot be relative, please specify an absolute path."), QMessageBox::Ok); + return false; + } + + QString checkString = targetDir(); +#ifdef Q_OS_WIN + // remove e.g. "c:" + checkString = checkString.mid(2); +#endif + // check if there are not allowed characters in the target path + if (checkString.contains(QRegExp(QLatin1String("[!@#$%^&*: ,;]")))) { + MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(), + QLatin1String("forbiddenTargetDirectory"), tr("Error"), + tr("The install directory cannot contain !@#$%^&*:,; or spaces, please specify a valid folder."), + QMessageBox::Ok); + return false; + } + + const QString remove = installer()->value(QLatin1String("RemoveTargetDir")); if (!QVariant(remove).toBool()) return true; - const QDir dir(targetDir()); + // the directory exists and is empty... if (dir.exists() && dir.entryList(QDir::AllEntries | QDir::NoDotAndDotDot).isEmpty()) return true; QFileInfo fi(targetDir()); if (fi.isDir()) { - if (dir == QDir::root()) { + if (dir == QDir::root() || dir == QDir::home()) { MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(), QLatin1String("forbiddenTargetDirectory"), tr("Error"), tr("As the install directory is completely deleted installing in %1 is forbidden") @@ -264,15 +286,14 @@ bool TargetDirectoryPageImpl::validatePage() QFileInfo fi2(targetDir() + QDir::separator() + fileName); if (fi2.exists()) { return askQuestion(QLatin1String("overwriteTargetDirectory"), - TargetDirectoryPageImpl::tr("The folder you selected exists already and " - "contains an installation.\nDo you want to overwrite it?")); + TargetDirectoryPageImpl::tr("The folder you selected exists already and contains an " + "installation.\nDo you want to overwrite it?")); } return askQuestion(QLatin1String("overwriteTargetDirectory"), - tr("You have selected an existing, non-empty folder for installation.\n" - "Note that it will be completely wiped on uninstallation of this application.\n" - "It is not advisable to install into this folder as installation might fail.\n" - "Do you want to continue?")); + tr("You have selected an existing, non-empty folder for installation.\nNote that it will be " + "completely wiped on uninstallation of this application.\nIt is not advisable to install into " + "this folder as installation might fail.\nDo you want to continue?")); } else if (fi.isFile() || fi.isSymLink()) { MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(), QLatin1String("WrongTargetDirectory"), tr("Error"), |