diff options
author | Friedemann Kleint <Friedemann.Kleint@digia.com> | 2012-11-29 17:20:34 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-11-30 15:21:38 +0100 |
commit | d7996b7637ae0bbc261c32b4f93dd07e66eeda7a (patch) | |
tree | d207669d8ad5d713fd1f5bb75672a2a6864b7562 /src/qml/qml/qqmlengine.cpp | |
parent | 18f42ab9b5e5b7bd9bd324af4c2ac449a5c2107e (diff) |
Limit case-sensitivity check in QML to file names.
Provide for checking relative paths only; default to file names.
Currently, the checking triggers on a drive letters and
installation folder names, which is too strict.
Task-number: QTBUG-28277
Change-Id: I1174bb0c485eeb1ffee10bb2a523d6629c57728b
Reviewed-by: Kai Koehne <kai.koehne@digia.com>
Diffstat (limited to 'src/qml/qml/qqmlengine.cpp')
-rw-r--r-- | src/qml/qml/qqmlengine.cpp | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp index 9db8927fd9..2a46cdb12e 100644 --- a/src/qml/qml/qqmlengine.cpp +++ b/src/qml/qml/qqmlengine.cpp @@ -2078,7 +2078,7 @@ bool QQmlEnginePrivate::isScriptLoaded(const QUrl &url) const return typeLoader.isScriptLoaded(url); } -bool QQml_isFileCaseCorrect(const QString &fileName) +bool QQml_isFileCaseCorrect(const QString &fileName, int lengthIn /* = -1 */) { #if defined(Q_OS_MAC) || defined(Q_OS_WIN) QFileInfo info(fileName); @@ -2100,7 +2100,21 @@ bool QQml_isFileCaseCorrect(const QString &fileName) const int absoluteLength = absolute.length(); const int canonicalLength = canonical.length(); - const int length = qMin(absoluteLength, canonicalLength); + int length = qMin(absoluteLength, canonicalLength); + if (lengthIn >= 0) { + length = qMin(lengthIn, length); + } else { + // No length given: Limit to file name. Do not trigger + // on drive letters or folder names. + int lastSlash = absolute.lastIndexOf(QLatin1Char('/')); + if (lastSlash < 0) + lastSlash = absolute.lastIndexOf(QLatin1Char('\\')); + if (lastSlash >= 0) { + const int fileNameLength = absoluteLength - 1 - lastSlash; + length = qMin(length, fileNameLength); + } + } + for (int ii = 0; ii < length; ++ii) { const QChar &a = absolute.at(absoluteLength - 1 - ii); const QChar &c = canonical.at(canonicalLength - 1 - ii); @@ -2111,6 +2125,7 @@ bool QQml_isFileCaseCorrect(const QString &fileName) return false; } #else + Q_UNUSED(lengthIn) Q_UNUSED(fileName) #endif return true; |