diff options
author | kh1 <karsten.heimrich@digia.com> | 2012-11-13 15:45:37 +0100 |
---|---|---|
committer | Karsten Heimrich <karsten.heimrich@digia.com> | 2012-11-14 12:04:15 +0100 |
commit | 0507fa96513a0542936644415efe4e14010b81c8 (patch) | |
tree | e30e1142bb5819372674a4353c0e5e6998defa77 /src | |
parent | d919121cb7ab0655165a67759cd9c2a80a31e3ff (diff) |
Check for valid drive. Disallow e.g. C:foo\bar
Task-number: QTIFW-165
Once we add a something after the colon and before the next slash,
the path will be interpreted relative to the current directory,
thus leading to unexpected installation directory.
Change-Id: I0f32f150707d1b3ca55bd93f230142dad4f7540a
Reviewed-by: Tim Jenssen <tim.jenssen@digia.com>
Reviewed-by: Kai Koehne <kai.koehne@digia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/sdk/installerbasecommons.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/sdk/installerbasecommons.cpp b/src/sdk/installerbasecommons.cpp index 9e8b8ab12..214b6e54b 100644 --- a/src/sdk/installerbasecommons.cpp +++ b/src/sdk/installerbasecommons.cpp @@ -371,15 +371,22 @@ QString TargetDirectoryPageImpl::targetDirWarning() const "absolute path."); } - QString dir = targetDir(); - QString ambiguousChars = QLatin1String("[<>|?*!@#$%^&:,; ]"); - if (packageManagerCore()->settings().allowSpaceInPath()) - ambiguousChars.remove(QLatin1Char(' ')); - + QString dir = QDir::toNativeSeparators(targetDir()); #ifdef Q_OS_WIN + if (dir.count() >= 3 && dir.indexOf(QRegExp(QLatin1String("[a-zA-Z]:"))) == 0 + && dir.at(2) != QLatin1Char('\\')) { + return TargetDirectoryPageImpl::tr("The path you have entered is not valid, please make sure to " + "specify a valid drive."); + } + // remove e.g. "c:" dir = dir.mid(2); #endif + + QString ambiguousChars = QLatin1String("[<>|?*!@#$%^&:,; ]"); + if (packageManagerCore()->settings().allowSpaceInPath()) + ambiguousChars.remove(QLatin1Char(' ')); + // check if there are not allowed characters in the target path if (dir.contains(QRegExp(ambiguousChars))) { return TargetDirectoryPageImpl::tr("The installation path must not contain %1, " |