From f9b6db12e3f1ebc5211f607e7483d8ded75e2df0 Mon Sep 17 00:00:00 2001 From: Zander Otavka Date: Wed, 3 Aug 2016 13:48:27 -0700 Subject: [PATCH] Fix parsing of embedded entity scripts Now correctly identifies when scripts are not urls as well as javascript: urls. --- libraries/script-engine/src/ScriptCache.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/libraries/script-engine/src/ScriptCache.cpp b/libraries/script-engine/src/ScriptCache.cpp index 2114289095..d80baf9a7b 100644 --- a/libraries/script-engine/src/ScriptCache.cpp +++ b/libraries/script-engine/src/ScriptCache.cpp @@ -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];