This repository was archived by the owner on Sep 3, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -55,6 +55,13 @@ public class ExtensionManager {
55
55
static public const wedoExt: String = 'LEGO WeDo' ;
56
56
static public const wedo2Ext: String = 'LEGO WeDo 2.0' ;
57
57
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
+
58
65
public function ExtensionManager (app :Scratch ) {
59
66
this . app = app;
60
67
clearImportedExtensions();
@@ -323,8 +330,19 @@ public class ExtensionManager {
323
330
extensionRefused(extObj, 'Experimental extensions are only supported on ScratchX.' );
324
331
continue ;
325
332
}
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 (', ' ));
328
346
continue ;
329
347
}
330
348
ext. javascriptURL = extObj. javascriptURL;
You can’t perform that action at this time.
0 commit comments