History

Fix parsing of embedded entity scripts

Now correctly identifies when scripts are not urls as well as javascript: urls.

Zander Otavka committed 10 years ago

Commit f9b6db11 parent 9962d471 file · +8 −1Browse files

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

Unified · Split

libraries/script-engine/src/ScriptCache.cpp+8−1
@@ -110,11 +110,18 @@ void ScriptCache::getScriptContents(const QString& scriptOrURL, contentAvailable · 109 unmodified lines
110 QUrl url = ResourceManager::normalizeURL(unnormalizedURL);110 QUrl url = ResourceManager::normalizeURL(unnormalizedURL);
111 111
112 // 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)112 // 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)
113 if (url.scheme().isEmpty() && scriptOrURL.simplified().replace(" ", "").contains("(function(){")) {113 if (unnormalizedURL.scheme().isEmpty() && scriptOrURL.simplified().replace(" ", "").contains("(function(){")) {
114 contentAvailable(scriptOrURL, scriptOrURL, false, true);114 contentAvailable(scriptOrURL, scriptOrURL, false, true);
115 return;115 return;
116 }116 }
117 117
118 // give a similar treatment to javacript: urls
119 if (unnormalizedURL.scheme() == "javascript") {
120 QString contents{ scriptOrURL };
121 contents.replace(QRegExp("^javascript:"), "");
122 contentAvailable(scriptOrURL, contents, false, true);
123 }
124
118 Lock lock(_containerLock);125 Lock lock(_containerLock);
119 if (_scriptCache.contains(url) && !forceDownload) {126 if (_scriptCache.contains(url) && !forceDownload) {
120 auto scriptContent = _scriptCache[url];127 auto scriptContent = _scriptCache[url];