Fix parsing of embedded entity scripts

Now correctly identifies when scripts are not urls as well as
javascript: urls.
This commit is contained in:
Zander Otavka 2016-08-03 13:48:27 -07:00
parent 9962d47173
commit f9b6db12e3

View file

@ -110,11 +110,18 @@ void ScriptCache::getScriptContents(const QString& scriptOrURL, contentAvailable
QUrl url = ResourceManager::normalizeURL(unnormalizedURL);
// attempt to determine if this is a URL to a script, or if this is actually a script itself (which is valid in the entityScript use case)
if (url.scheme().isEmpty() && scriptOrURL.simplified().replace(" ", "").contains("(function(){")) {
if (unnormalizedURL.scheme().isEmpty() && scriptOrURL.simplified().replace(" ", "").contains("(function(){")) {
contentAvailable(scriptOrURL, scriptOrURL, false, true);
return;
}
// give a similar treatment to javacript: urls
if (unnormalizedURL.scheme() == "javascript") {
QString contents{ scriptOrURL };
contents.replace(QRegExp("^javascript:"), "");
contentAvailable(scriptOrURL, contents, false, true);
}
Lock lock(_containerLock);
if (_scriptCache.contains(url) && !forceDownload) {
auto scriptContent = _scriptCache[url];