Commit 24420f9d authored by Anssi Piirainen's avatar Anssi Piirainen
Browse files

Generate secondary top level domains based on info in a separate tld repo.

parent c15c4e63
......@@ -6,6 +6,7 @@ Version history:
- The clip property 'bufferLength' now accepts decimal values, for example bufferLength: 0.2
- #121 only load plugins and external config from the same domain as the player swf from loaded from
- Made it possible to tab out of the player and into the HTML page using the keyboard alone.
- Change links in the context menu and in the logos to point to http://flash.flowplayer.org
3.2.16
------
......
......@@ -31,7 +31,7 @@ package org.flowplayer.view {
public static function validate(swfUrl:String, version:Array, configuredKeys:Object, externalInterfaceAvailable:Boolean):Boolean {
trace("using validator " + FlowplayerLicenseKey.id);
return FlowplayerLicenseKey.validate(swfUrl, version, configuredKeys, externalInterfaceAvailable);
return FlowplayerLicenseKey.validate(swfUrl, version, configuredKeys, (CONFIG::secondaryDomains).split(" "), externalInterfaceAvailable);
}
}
......
......@@ -162,6 +162,7 @@ package org.flowplayer.view {
addCallback("setKeyboardShortcutsEnabled", setKeyboardShortcutsEnabled);
addCallback("isKeyboardShortcutsEnabled", isKeyboardShortcutsEnabled);
addCallback("validateKey", validateKey);
addCallback("checkKeyInDomain", checkKeyInDomain);
addCallback("bufferAnimate", bufferAnimate);
......@@ -380,10 +381,15 @@ package org.flowplayer.view {
};
}
private function validateKey(key:Object, pageDomain:Boolean):Boolean {
var LicenseKey:Class = Class(getDefinitionByName("org.flowplayer.view.LicenseKey"));
return LicenseKey["validate"](_canvas.loaderInfo.url, version, key, pageDomain);
}
private function validateKey(key:Object, pageDomain:Boolean):Boolean {
var LicenseKey:Class = Class(getDefinitionByName("org.flowplayer.view.LicenseKey"));
return LicenseKey["validate"](_canvas.loaderInfo.url, version, key, pageDomain);
}
private function checkKeyInDomain(key:Object, domain:String):Boolean {
var LicenseKey:Class = Class(getDefinitionByName("org.flowplayer.view.LicenseKey"));
return LicenseKey["validate"](domain, version, key, false);
}
}
}
......@@ -16,67 +16,57 @@
* along with Flowplayer. If not, see <http://www.gnu.org/licenses/>.
*/
package org.flowplayer.view {
import flash.external.ExternalInterface;
import org.flowplayer.config.Config;
import org.flowplayer.config.ConfigParser;
import org.flowplayer.config.ExternalInterfaceHelper;
import org.flowplayer.config.VersionInfo;
import org.flowplayer.controller.PlayListController;
import org.flowplayer.controller.ResourceLoader;
import org.flowplayer.controller.ResourceLoaderImpl;
import org.flowplayer.flow_internal;
import org.flowplayer.model.Callable;
import org.flowplayer.model.Clip;
import org.flowplayer.model.ClipEvent;
import flash.display.BlendMode;
import flash.display.DisplayObject;
import flash.display.DisplayObjectContainer;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.events.TimerEvent;
import flash.net.URLRequest;
import flash.net.navigateToURL;
import flash.system.Capabilities;
import flash.system.Security;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.utils.*;
import org.flowplayer.config.Config;
import org.flowplayer.config.ConfigParser;
import org.flowplayer.config.ExternalInterfaceHelper;
import org.flowplayer.config.VersionInfo;
import org.flowplayer.controller.PlayListController;
import org.flowplayer.controller.ResourceLoader;
import org.flowplayer.controller.ResourceLoaderImpl;
import org.flowplayer.flow_internal;
import org.flowplayer.model.Callable;
import org.flowplayer.model.Clip;
import org.flowplayer.model.ClipEvent;
import org.flowplayer.model.ClipEventType;
import org.flowplayer.model.DisplayPluginModel;
import org.flowplayer.model.DisplayProperties;
import org.flowplayer.model.DisplayPropertiesImpl;
import org.flowplayer.model.ErrorCode;
import org.flowplayer.model.EventDispatcher;
import org.flowplayer.model.Loadable;
import org.flowplayer.model.Logo;
import org.flowplayer.model.PlayButtonOverlay;
import org.flowplayer.model.PlayerError;
import org.flowplayer.model.PlayerEvent;
import org.flowplayer.model.Playlist;
import org.flowplayer.model.Plugin;
import org.flowplayer.model.PluginError;
import org.flowplayer.model.PluginEvent;
import org.flowplayer.model.PluginModel;
import org.flowplayer.model.ProviderModel;
import org.flowplayer.model.State;
import org.flowplayer.util.Arrange;
import org.flowplayer.util.Log;
import org.flowplayer.util.TextUtil;
import org.flowplayer.util.URLUtil;
import org.flowplayer.view.Panel;
import org.flowplayer.view.PluginLoader;
import org.flowplayer.view.Screen;
import org.flowplayer.view.KeyboardHandler;
import org.osflash.thunderbolt.Logger;
import flash.display.DisplayObject;
import flash.display.DisplayObjectContainer;
import flash.display.Sprite;
import flash.display.BlendMode;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.events.TimerEvent;
import flash.net.URLRequest;
import flash.net.navigateToURL;
import flash.system.Capabilities;
import flash.system.Security;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.utils.*;
CONFIG::FLASH_10_1 {
import org.flowplayer.model.DisplayProperties;
import org.flowplayer.model.ErrorCode;
import org.flowplayer.model.Loadable;
import org.flowplayer.model.Logo;
import org.flowplayer.model.PlayButtonOverlay;
import org.flowplayer.model.PlayerError;
import org.flowplayer.model.PlayerEvent;
import org.flowplayer.model.Playlist;
import org.flowplayer.model.Plugin;
import org.flowplayer.model.PluginEvent;
import org.flowplayer.model.PluginModel;
import org.flowplayer.model.ProviderModel;
import org.flowplayer.model.State;
import org.flowplayer.util.Arrange;
import org.flowplayer.model.EventDispatcher;
import org.flowplayer.util.Log;
import org.flowplayer.util.TextUtil;
import org.flowplayer.util.URLUtil;
import org.osflash.thunderbolt.Logger;
CONFIG::FLASH_10_1 {
import flash.media.StageVideo;
}
}
use namespace flow_internal;
public class Launcher extends StyleableSprite implements ErrorHandler {
......@@ -296,7 +286,7 @@ import org.flowplayer.model.DisplayPluginModel;
var plugins:Array = _config.getLoadables();
log.debug("will load following plugins: ");
logPluginInfo(plugins);
_pluginLoader = new PluginLoader(URLUtil.playerBaseUrl, _pluginRegistry, this, useExternalInterface());
_pluginLoader = new PluginLoader(URLUtil.playerBaseUrl, _pluginRegistry, this, useExternalInterface(), (CONFIG::secondaryDomains).split(" "));
_pluginLoader.addEventListener(Event.COMPLETE, pluginLoadListener);
_flowplayer.pluginLoader = _pluginLoader;
if (plugins.length == 0) {
......
......@@ -75,13 +75,15 @@ import org.flowplayer.util.URLUtil;
private var _allPlugins:Array;
private var _loaderContext:LoaderContext;
private var _loadStartedCount:int = 0;
private var _secondaries:Array;
public function PluginLoader(baseUrl:String, pluginRegistry:PluginRegistry, errorHandler:ErrorHandler, useExternalInterface:Boolean) {
public function PluginLoader(baseUrl:String, pluginRegistry:PluginRegistry, errorHandler:ErrorHandler, useExternalInterface:Boolean, secondaries:Array) {
_baseUrl = baseUrl;
_pluginRegistry = pluginRegistry;
_errorHandler = errorHandler;
_useExternalInterface = useExternalInterface;
_loadedCount = 0;
_secondaries = secondaries;
}
private function constructUrl(url:String):String {
......@@ -160,7 +162,7 @@ import org.flowplayer.util.URLUtil;
if (! loadable.isBuiltIn && loadable.url && result.indexOf(loadable.url) < 0) {
var pluginUrl:String = constructUrl(loadable.url);
if (DomainUtil.allowCodeLoading(pluginUrl)) {
if (DomainUtil.allowCodeLoading(pluginUrl, _secondaries)) {
result.push(pluginUrl);
} else {
log.error("Unable to load plugin from " + loadable.url);
......
......@@ -18,9 +18,9 @@
id="player">
</a>
<script>
flowplayer("player", "../../../flash-build/build/flowplayer.swf",
flowplayer("player", "../../../flash-build/build/flowplayer.commercial-3.2.17-dev.swf",
{
log: { level: 'debug', filter: 'org.flowplayer.view.PluginLoader'},
log: { level: 'debug', filter: 'org.flowplayer.util.DomainUtil'},
key: '#$b6223bfbd646c621758',
......@@ -82,11 +82,9 @@
// duration: 20
},
plugins: {
controls: {
url: "http://releases.flowplayer.org/swf/flowplayer.controls.swf"
}
}
plugins: {
content: { url: 'flowplayer.rtmp.swf' }
}
});
......
......@@ -9,7 +9,8 @@
* http://www.opensource.org/licenses/mit-license.php
*/
package org.flowplayer.util {
public class DomainUtil {
public class DomainUtil {
// private static var log:Log = new Log("org.flowplayer.util::DomainUtil");
/**
* Parses and returns the domain name from the specified URL.
......@@ -17,7 +18,7 @@ package org.flowplayer.util {
* @param stripSubdomains if true the top private domain name is returned with other subdomains stripped out
* @return
*/
public static function parseDomain(url:String, stripSubdomains:Boolean):String {
public static function parseDomain(url:String, stripSubdomains:Boolean, secondaries:Array):String {
var domain:String = getDomain(url);
if (stripSubdomains || domain.indexOf("www.") == 0) {
if (hasAllNumbers(domain)) {
......@@ -25,7 +26,7 @@ package org.flowplayer.util {
return parseIPAddressDomain(domain);
}
domain = stripSubdomain(domain);
domain = stripSubdomain(domain, secondaries);
trace("stripped out subdomain, resulted in " + domain);
}
return domain.toLowerCase();
......@@ -51,33 +52,8 @@ package org.flowplayer.util {
return !isNaN(parseFloat(n)) && isFinite(n as Number);
}
public static function stripSubdomain(host:String):String {
var secondaries:Array = ('co.uk,org.uk,ltd.uk,plc.uk,me.uk,br.com,cn.com,eu.com,hu.com,no.com,qc.com,sa.com' +
'se.com,se.net,us.com,uy.com,co.ac,gv.ac,or.ac,ac.ac,ac.at,co.at,gv.at,or.at' +
'asn.au,com.au,edu.au,org.au,net.au,id.au,ac.be,adm.br,adv.br,am.br,arq.br,art.br' +
'bio.br,cng.br,cnt.br,com.br,ecn.br,eng.br,esp.br,etc.br,eti.br,fm.br,fot.br,fst.br' +
'g12.br,gov.br,ind.br,inf.br,jor.br,lel.br,med.br,mil.br,net.br,nom.br,ntr.br' +
'odo.br,org.br,ppg.br,pro.br,psc.br,psi.br,rec.br,slg.br,tmp.br,tur.br,tv.br,vet.br' +
'zlg.br,ab.ca,bc.ca,mb.ca,nb.ca,nf.ca,ns.ca,nt.ca,on.ca,pe.ca,qc.ca,sk.ca,yk.ca' +
'ac.cn,com.cn,edu.cn,gov.cn,org.cn,bj.cn,sh.cn,tj.cn,cq.cn,he.cn,nm.cn,ln.cn' +
'jl.cn,hl.cn,js.cn,zj.cn,ah.cn,gd.cn,gx.cn,hi.cn,sc.cn,gz.cn,yn.cn,xz.cn,sn.cn' +
'gs.cn,qh.cn,nx.cn,xj.cn,tw.cn,hk.cn,mo.cn,com.ec,tm.fr,com.fr,asso.fr,presse.fr' +
'co.il,net.il,ac.il,k12.il,gov.il,muni.il,ac.in,co.in,org.in,ernet.in,gov.in' +
'net.in,res.in,ac.jp,co.jp,go.jp,or.jp,ne.jp,ac.kr,co.kr,go.kr,ne.kr,nm.kr,or.kr' +
'asso.mc,tm.mc,com.mm,org.mm,net.mm,edu.mm,gov.mm,org.ro,store.ro,tm.ro,firm.ro' +
'www.ro,arts.ro,rec.ro,info.ro,nom.ro,nt.ro,com.sg,org.sg,net.sg,gov.sg,ac.th,co.th' +
'go.th,mi.th,net.th,or.th,com.tr,edu.tr,gov.tr,k12.tr,net.tr,org.tr,com.tw,org.tw' +
'net.tw,ac.uk,uk.com,uk.net,gb.com,gb.net,com.hk,org.hk,net.hk,edu.hk,eu.lv,co.nz' +
'org.nz,net.nz,maori.nz,iwi.nz,com.pt,edu.pt,com.ve,net.ve,org.ve,web.ve,info.ve' +
'co.ve,net.ru,org.ru,com.hr,tv.tr,com.qa,edu.qa,gov.qa,gov.au,com.my,edu.my,gov.my' +
'co.za,com.ar,com.pl,com.ua,biz.pl,biz.tr,co.gl,co.mg,co.ms,co.vi,co.za,com.ag' +
'com.ai,com.cy,com.de,com.do,com.es,com.fj,com.gl,com.gt,com.hu,com.kg,com.ki' +
'com.lc,com.mg,com.ms,com.mt,com.mu,com.mx,com.nf,com.ng,com.ni,com.pa,com.ph' +
'com.ro,com.ru,com.sb,com.sc,com.sv,de.com,de.org,firm.in,gen.in,idv.tw,ind.in' +
'info.pl,info.tr,kr.com,me.uk,net.ag,net.ai,net.cn,net.do,net.gl,net.kg,net.ki' +
'net.lc,net.mg,net.mu,net.ni,net.pl,net.sb,net.sc,nom.ni,off.ai,org.ag,org.ai' +
'org.do,org.es,org.gl,org.kg,org.ki,org.lc,org.mg,org.ms,org.nf,org.ni,org.pl' +
'org.sb,org.sc').split(',');
public static function stripSubdomain(host:String, secondaries:Array):String {
// log.debug("secondaries: " + secondaries);
host = host.toLowerCase();
var bits:Array = host.split(".");
......@@ -128,14 +104,14 @@ package org.flowplayer.util {
return false;
}
public static function allowCodeLoading(resourceUrl:String):Boolean {
public static function allowCodeLoading(resourceUrl:String, secondaries:Array):Boolean {
if (! URLUtil.isCompleteURLWithProtocol(resourceUrl)) return true;
var playerUrl:String = URLUtil.playerBaseUrl;
if (isLocal(playerUrl)) return true;
var playerDomain:String = parseDomain(playerUrl, true);
var resourceDomain:String = parseDomain(resourceUrl, true);
var playerDomain:String = parseDomain(playerUrl, true, secondaries);
var resourceDomain:String = parseDomain(resourceUrl, true, secondaries);
trace("player domain " + playerDomain);
trace("resource domain " + resourceDomain);
......
......@@ -14,5 +14,6 @@
<property name="plugin-main-class" value="org/flowplayer/securestreaming/SecureStreamingPlugin.as" />
<property name="library-path" value="lib/corelib" />
<property name="extra-sources" value="../../lib/common/src/actionscript"/>
<property name="compiler-defines" value="-define+=CONFIG::FLASH_10_1,'true'"/>
</project>
\ No newline at end of file
......@@ -92,7 +92,7 @@ package org.flowplayer.securestreaming {
}
private static function checkDomain(url:String, acceptedDomains:Array):Boolean {
var domain:String = DomainUtil.parseDomain(url, true);
var domain:String = DomainUtil.parseDomain(url, true, (CONFIG::secondaryDomains).split(" "));
// log.debug("domain is '" + domain + "'");
return acceptedDomains.indexOf(domain) >= 0;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment