Skip to content

Commit

Permalink
Only allow unsandboxed extensions to use BlockType.XML
Browse files Browse the repository at this point in the history
  • Loading branch information
GarboMuffin committed Aug 7, 2023
1 parent ab0bd7e commit 9925597
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/extension-support/extension-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ const createExtensionService = extensionManager => {
return service;
};

/**
* @param {string} serviceName Dispatch service name.
* @returns {boolean} True if the extension can be granted extra permissions.
*/
const isTrustedService = serviceName => serviceName.startsWith('unsandboxed.');

class ExtensionManager {
constructor (vm) {
/**
Expand Down Expand Up @@ -494,6 +500,9 @@ class ExtensionManager {
*/
_prepareBlockInfo (serviceName, blockInfo) {
if (blockInfo.blockType === BlockType.XML) {
if (!isTrustedService(serviceName)) {
throw new Error('BlockType.XML only supported in unsandboxed extensions')
}
blockInfo = Object.assign({}, blockInfo);
blockInfo.xml = String(blockInfo.xml) || '';
return blockInfo;
Expand Down

0 comments on commit 9925597

Please sign in to comment.