History

Disable whitelist on entity_server scripts.

Kasen IO committed 6 years ago

Commit fb5dbfc1 parent d872e9f1 file · +15 −9Browse 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+15−9
@@ -2377,15 +2377,21 @@ void ScriptEngine::entityScriptContentAvailable(const EntityItemID& entityID, co · 2376 unmodified lines
23772377 // END PULL SAFEURLS FROM INTERFACE.JSON Settings
23782378
23792379 bool isInWhitelist = false; // assume unsafe
2380− for (const auto& str : safeURLS) {
2381− qCDebug(scriptengine) << whitelistPrefix << "Script URL: " << scriptOrURL << "TESTING AGAINST" << str << "RESULTS IN"
2382− << scriptOrURL.startsWith(str);
2383− if (!str.isEmpty() && scriptOrURL.startsWith(str)) {
2384− isInWhitelist = true;
2385− qCDebug(scriptengine) << whitelistPrefix << "Script approved.";
2386− break; // bail early since we found a match
2387− }
2388− }
2380+
2381+ if(ScriptEngine::getContext() == "entity_server") {
2382+ isInWhitelist = true;
2383+ } else {
2384+ for (const auto& str : safeURLS) {
2385+ qCDebug(scriptengine) << whitelistPrefix << "Script URL: " << scriptOrURL << "TESTING AGAINST" << str << "RESULTS IN"
2386+ << scriptOrURL.startsWith(str);
2387+ if (!str.isEmpty() && scriptOrURL.startsWith(str)) {
2388+ isInWhitelist = true;
2389+ qCDebug(scriptengine) << whitelistPrefix << "Script approved.";
2390+ break; // bail early since we found a match
2391+ }
2392+ }
2393+ }
2394+
23892395 if (!isInWhitelist) {
23902396 qCDebug(scriptengine) << whitelistPrefix << "(disabled entity script)" << entityID.toString() << scriptOrURL;
23912397 exception = makeError("UNSAFE_ENTITY_SCRIPTS == 0");