Skip to content
This repository was archived by the owner on Sep 3, 2019. It is now read-only.

Commit 1f540f7

Browse files
cwillisfChristopher Willis-Ford
authored andcommitted
Merge pull request #1130 from LLK/allow-coding.me-extensions
Allow experimental extensions from coding.me
1 parent 9f209f7 commit 1f540f7

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

src/extensions/ExtensionManager.as

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,13 @@ public class ExtensionManager {
5555
static public const wedoExt:String = 'LEGO WeDo';
5656
static public const wedo2Ext:String = 'LEGO WeDo 2.0';
5757

58+
// Experimental extensions must be hosted on one of these domains
59+
// These should start with '.' to avoid accepting things like 'malicious.not_github.io'
60+
static public const allowedDomains:Vector.<String> = new <String>[
61+
'.github.io',
62+
'.coding.me'
63+
];
64+
5865
public function ExtensionManager(app:Scratch) {
5966
this.app = app;
6067
clearImportedExtensions();
@@ -323,8 +330,19 @@ public class ExtensionManager {
323330
extensionRefused(extObj, 'Experimental extensions are only supported on ScratchX.');
324331
continue;
325332
}
326-
if (!StringUtil.endsWith(URLUtil.getServerName(extObj.javascriptURL).toLowerCase(),'.github.io')) {
327-
extensionRefused(extObj, 'Experimental extensions must be hosted on GitHub Pages.');
333+
var domainAllowed:Boolean = false;
334+
var url:String = URLUtil.getServerName(extObj.javascriptURL).toLowerCase();
335+
for (var i:int = 0; i < allowedDomains.length; ++i) {
336+
if (StringUtil.endsWith(url, allowedDomains[i])) {
337+
domainAllowed = true;
338+
break;
339+
}
340+
}
341+
if (!domainAllowed) {
342+
extensionRefused(
343+
extObj,
344+
'Experimental extensions must be hosted on an approved domain. Approved domains are: ' +
345+
allowedDomains.join(', '));
328346
continue;
329347
}
330348
ext.javascriptURL = extObj.javascriptURL;

0 commit comments

Comments
 (0)