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
110110 QUrl url = ResourceManager::normalizeURL(unnormalizedURL);
111111
112112 // 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(){")) {
114114 contentAvailable(scriptOrURL, scriptOrURL, false, true);
115115 return;
116116 }
117117
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+
118125 Lock lock(_containerLock);
119126 if (_scriptCache.contains(url) && !forceDownload) {
120127 auto scriptContent = _scriptCache[url];