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

Commit

Permalink
Merge pull request #1130 from LLK/allow-coding.me-extensions
Browse files Browse the repository at this point in the history
Allow experimental extensions from coding.me
  • Loading branch information
cwillisf authored and Christopher Willis-Ford committed Jun 14, 2016
1 parent 9f209f7 commit 1f540f7
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions src/extensions/ExtensionManager.as
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ public class ExtensionManager {
static public const wedoExt:String = 'LEGO WeDo';
static public const wedo2Ext:String = 'LEGO WeDo 2.0';

// Experimental extensions must be hosted on one of these domains
// These should start with '.' to avoid accepting things like 'malicious.not_github.io'
static public const allowedDomains:Vector.<String> = new <String>[
'.github.io',
'.coding.me'
];

public function ExtensionManager(app:Scratch) {
this.app = app;
clearImportedExtensions();
Expand Down Expand Up @@ -323,8 +330,19 @@ public class ExtensionManager {
extensionRefused(extObj, 'Experimental extensions are only supported on ScratchX.');
continue;
}
if (!StringUtil.endsWith(URLUtil.getServerName(extObj.javascriptURL).toLowerCase(),'.github.io')) {
extensionRefused(extObj, 'Experimental extensions must be hosted on GitHub Pages.');
var domainAllowed:Boolean = false;
var url:String = URLUtil.getServerName(extObj.javascriptURL).toLowerCase();
for (var i:int = 0; i < allowedDomains.length; ++i) {
if (StringUtil.endsWith(url, allowedDomains[i])) {
domainAllowed = true;
break;
}
}
if (!domainAllowed) {
extensionRefused(
extObj,
'Experimental extensions must be hosted on an approved domain. Approved domains are: ' +
allowedDomains.join(', '));
continue;
}
ext.javascriptURL = extObj.javascriptURL;
Expand Down

0 comments on commit 1f540f7

Please sign in to comment.