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
84 url.setPath(defaultScriptsLoc.path() + "/" + splitPath.mid(2).join("/")); // 2 to skip the slashes in /~/84 url.setPath(defaultScriptsLoc.path() + "/" + splitPath.mid(2).join("/")); // 2 to skip the slashes in /~/
85 85
86 // stop something like Script.include(["/~/../Users/james/Desktop/naughty.js"]); from working86 // stop something like Script.include(["/~/../Users/james/Desktop/naughty.js"]); from working
87 QFileInfo fileInfo(url.path());87 qDebug() << "url: " << url.path();
88 url.setPath(fileInfo.absoluteFilePath());88 qDebug() << "BEFORE: " << url.path();
89 89 QFileInfo fileInfo(url.toLocalFile());
90 if (!url.path().startsWith(defaultScriptsLoc.path())) {90 url = QUrl::fromLocalFile(fileInfo.absoluteFilePath());
91 qDebug() << "AFTER: " << url.path();
92 qDebug() << "default: " << defaultScriptsLoc.path();
93
94 if (!defaultScriptsLoc.isParentOf(url)) {
91 qCWarning(scriptengine) << "Script.include() ignoring file path" << normalizedScriptURL95 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("");
93 }98 }
94 return url;99 return url;
95 }100 }