History

trying to get /~/ from web sorted out

Seth Alves committed 10 years ago

Commit 8c2b89b1 parent 82b43db1 file · +10 −5Browse files

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

Unified · Split

libraries/script-engine/src/ScriptEngines.cpp+10−5
@@ -84,12 +84,17 @@ QUrl expandScriptUrl(const QUrl& rawScriptURL) { · 83 unmodified lines
8484 url.setPath(defaultScriptsLoc.path() + "/" + splitPath.mid(2).join("/")); // 2 to skip the slashes in /~/
8585
8686 // stop something like Script.include(["/~/../Users/james/Desktop/naughty.js"]); from working
87− QFileInfo fileInfo(url.path());
88− url.setPath(fileInfo.absoluteFilePath());
89−
90− if (!url.path().startsWith(defaultScriptsLoc.path())) {
87+ qDebug() << "url: " << url.path();
88+ qDebug() << "BEFORE: " << url.path();
89+ QFileInfo fileInfo(url.toLocalFile());
90+ url = QUrl::fromLocalFile(fileInfo.absoluteFilePath());
91+ qDebug() << "AFTER: " << url.path();
92+ qDebug() << "default: " << defaultScriptsLoc.path();
93+
94+ if (!defaultScriptsLoc.isParentOf(url)) {
9195 qCWarning(scriptengine) << "Script.include() ignoring file path" << normalizedScriptURL
92− << "outside of standard libraries";
96+ << "outside of standard libraries" << url.path() << defaultScriptsLoc.path();
97+ // return QUrl("");
9398 }
9499 return url;
95100 }