History

Fixes bools and tab.

Kasen IO committed 6 years ago

Commit 13d79fe1 parent d87cd011 file · +11 −12Browse files

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

Unified · Split

libraries/script-engine/src/ScriptEngine.cpp+11−12
@@ -2361,10 +2361,9 @@ void ScriptEngine::entityScriptContentAvailable(const EntityItemID& entityID, co · 2360 unmodified lines
23612361 }
23622362 }
23632363 else {
2364− // ENTITY SCRIPT WHITELIST STARTS HERE
2364+ // ENTITY SCRIPT WHITELIST STARTS HERE
23652365 auto nodeList = DependencyManager::get<NodeList>();
2366− bool isInWhitelist = false; // assume unsafe
2367− bool autoPassList = false;
2366+ bool passList = false; // assume unsafe
23682367 QString whitelistPrefix = "[WHITELIST ENTITY SCRIPTS]";
23692368 QList<QString> safeURLS = { "file:///", "atp:", "cache:" };
23702369 safeURLS += qEnvironmentVariable("EXTRA_WHITELIST").trimmed().split(QRegExp("\\s*,\\s*"), QString::SkipEmptyParts);
@@ -2372,14 +2371,13 @@ void ScriptEngine::entityScriptContentAvailable(const EntityItemID& entityID, co · 1 unmodified line
23722371 // IF WHITELIST IS DISABLED IN SETTINGS
23732372 bool whitelistEnabled = Setting::Handle<bool>("private/whitelistEnabled", true).get();
23742373 if (!whitelistEnabled) {
2375− autoPassList = true;
2374+ passList = true;
23762375 }
2377− // PULL SAFEURLS FROM INTERFACE.JSON Settings
23782376
2377+ // PULL SAFEURLS FROM INTERFACE.JSON Settings
23792378 QVariant raw = Setting::Handle<QVariant>("private/settingsSafeURLS").get();
23802379 QStringList settingsSafeURLS = raw.toString().trimmed().split(QRegExp("\\s*[,\r\n]+\\s*"), QString::SkipEmptyParts);
23812380 safeURLS += settingsSafeURLS;
2382−
23832381 // END PULL SAFEURLS FROM INTERFACE.JSON Settings
23842382
23852383 // GET CURRENT DOMAIN WHITELIST BYPASS, IN CASE AN ENTIRE DOMAIN IS WHITELISTED
@@ -2392,27 +2390,28 @@ void ScriptEngine::entityScriptContentAvailable(const EntityItemID& entityID, co · 6 unmodified lines
23922390 qCDebug(scriptengine) << whitelistPrefix << "Whitelist Bypassed. Current Domain Host: "
23932391 << nodeList->getDomainHandler().getHostname()
23942392 << "Current Domain: " << currentDomain;
2395− isInWhitelist = true;
2396− autoPassList = true;
2393+ passList = true;
23972394 }
23982395 }
23992396 // END CURRENT DOMAIN WHITELIST BYPASS
24002397
2401− if (ScriptEngine::getContext() == "entity_server" || autoPassList == true) { // If running on the server or waved through, do not engage whitelist.
2402− isInWhitelist = true;
2398+ // START CHECKING AGAINST THE WHITELIST
2399+ if (ScriptEngine::getContext() == "entity_server" || passList == true) { // If running on the server or waved through, do not engage whitelist.
2400+ passList = true;
24032401 } else {
24042402 for (const auto& str : safeURLS) {
24052403 qCDebug(scriptengine) << whitelistPrefix << "Script URL: " << scriptOrURL << "TESTING AGAINST" << str << "RESULTS IN"
24062404 << scriptOrURL.startsWith(str);
24072405 if (!str.isEmpty() && scriptOrURL.startsWith(str)) {
2408− isInWhitelist = true;
2406+ passList = true;
24092407 qCDebug(scriptengine) << whitelistPrefix << "Script approved.";
24102408 break; // bail early since we found a match
24112409 }
24122410 }
24132411 }
2412+ // END CHECKING AGAINST THE WHITELIST
24142413
2415− if (!isInWhitelist || autoPassList == false) {
2414+ if (!passList) { // If the entity failed to pass for any reason, it's blocked and an error is thrown.
24162415 qCDebug(scriptengine) << whitelistPrefix << "(disabled entity script)" << entityID.toString() << scriptOrURL;
24172416 exception = makeError("UNSAFE_ENTITY_SCRIPTS == 0");
24182417 } else {