History

fix problem where canonicalFilePath will strip a trailing slash

Seth Alves committed 10 years ago

Commit b28cfd21 parent 36e84e63 files · +11 −10Browse files

Showing the changes to libraries/script-engine/src/ScriptEngines.cpp (1 of 3 files). Show all

Unified · Split

libraries/script-engine/src/ScriptEngines.cpp+3−6
@@ -89,13 +89,7 @@ QUrl expandScriptUrl(const QUrl& rawScriptURL) { · 88 unmodified lines
89 89
90 // stop something like Script.include(["/~/../Desktop/naughty.js"]); from working90 // stop something like Script.include(["/~/../Desktop/naughty.js"]); from working
91 QFileInfo fileInfo(url.toLocalFile());91 QFileInfo fileInfo(url.toLocalFile());
92 #if defined(Q_OS_WIN)
93 url = QUrl::fromLocalFile(fileInfo.canonicalFilePath().toLower());
94 #elif defined(Q_OS_OSX)
95 url = QUrl::fromLocalFile(fileInfo.canonicalFilePath().toLower());
96 #else
97 url = QUrl::fromLocalFile(fileInfo.canonicalFilePath());92 url = QUrl::fromLocalFile(fileInfo.canonicalFilePath());
98 #endif
99 93
100 QUrl defaultScriptsLoc = defaultScriptsLocation();94 QUrl defaultScriptsLoc = defaultScriptsLocation();
101 if (!defaultScriptsLoc.isParentOf(url)) {95 if (!defaultScriptsLoc.isParentOf(url)) {
@@ -105,6 +99,9 @@ QUrl expandScriptUrl(const QUrl& rawScriptURL) { · 3 unmodified lines
105 << defaultScriptsLoc.path();99 << defaultScriptsLoc.path();
106 return rawScriptURL;100 return rawScriptURL;
107 }101 }
102 if (rawScriptURL.path().endsWith("/") && !url.path().endsWith("/")) {
103 url.setPath(url.path() + "/");
104 }
108 return url;105 return url;
109 }106 }
110 return normalizedScriptURL;107 return normalizedScriptURL;