mirror of
https://github.com/overte-org/overte.git
synced 2025-04-25 15:14:19 +02:00
fix problem where canonicalFilePath will strip a trailing slash
This commit is contained in:
parent
36e84e6266
commit
b28cfd27ec
3 changed files with 13 additions and 12 deletions
|
@ -874,6 +874,7 @@ QUrl ScriptEngine::resolvePath(const QString& include) const {
|
|||
}
|
||||
|
||||
// at this point we should have a legitimate fully qualified URL for our parent
|
||||
qDebug() << "ScriptEngine::resolvePath" << parentURL << url;
|
||||
url = expandScriptUrl(parentURL.resolved(url));
|
||||
return url;
|
||||
}
|
||||
|
|
|
@ -89,13 +89,7 @@ QUrl expandScriptUrl(const QUrl& rawScriptURL) {
|
|||
|
||||
// stop something like Script.include(["/~/../Desktop/naughty.js"]); from working
|
||||
QFileInfo fileInfo(url.toLocalFile());
|
||||
#if defined(Q_OS_WIN)
|
||||
url = QUrl::fromLocalFile(fileInfo.canonicalFilePath().toLower());
|
||||
#elif defined(Q_OS_OSX)
|
||||
url = QUrl::fromLocalFile(fileInfo.canonicalFilePath().toLower());
|
||||
#else
|
||||
url = QUrl::fromLocalFile(fileInfo.canonicalFilePath());
|
||||
#endif
|
||||
|
||||
QUrl defaultScriptsLoc = defaultScriptsLocation();
|
||||
if (!defaultScriptsLoc.isParentOf(url)) {
|
||||
|
@ -105,6 +99,9 @@ QUrl expandScriptUrl(const QUrl& rawScriptURL) {
|
|||
<< defaultScriptsLoc.path();
|
||||
return rawScriptURL;
|
||||
}
|
||||
if (rawScriptURL.path().endsWith("/") && !url.path().endsWith("/")) {
|
||||
url.setPath(url.path() + "/");
|
||||
}
|
||||
return url;
|
||||
}
|
||||
return normalizedScriptURL;
|
||||
|
|
|
@ -56,12 +56,15 @@ QString findMostRecentFileExtension(const QString& originalFileName, QVector<QSt
|
|||
}
|
||||
|
||||
QUrl defaultScriptsLocation() {
|
||||
#ifdef Q_OS_WIN
|
||||
return QUrl(("file:///" + QCoreApplication::applicationDirPath()).toLower() + "/scripts");
|
||||
#elif defined(Q_OS_OSX)
|
||||
return QUrl(("file://" + QCoreApplication::applicationDirPath() + "/../Resources/scripts").toLower());
|
||||
#else
|
||||
// return "http://s3.amazonaws.com/hifi-public";
|
||||
return QUrl("file://" + QCoreApplication::applicationDirPath() + "/scripts");
|
||||
#ifdef Q_OS_WIN
|
||||
QString path = QCoreApplication::applicationDirPath() + "/scripts";
|
||||
#elif defined(Q_OS_OSX)
|
||||
QString path = QCoreApplication::applicationDirPath() + "/../Resources/scripts";
|
||||
#else
|
||||
QString path = QCoreApplication::applicationDirPath() + "/scripts";
|
||||
#endif
|
||||
|
||||
QFileInfo fileInfo(path);
|
||||
return QUrl::fromLocalFile(fileInfo.canonicalFilePath());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue