8
8
* - http://www.gnu.org/copyleft/gpl.html
9
9
*
10
10
* Author: Mark J Panaghiston
11
- * Version: 2.3.0
12
- * Date: 20th April 2013
11
+ * Version: 2.3.1
12
+ * Date: 14th May 2013
13
13
*
14
14
* FlashVars expected: (AS3 property of: loaderInfo.parameters)
15
15
* id: (URL Encoded: String) Id of jPlayer instance
@@ -69,15 +69,14 @@ package {
69
69
private var isMp3: Boolean = false ;
70
70
private var isVideo: Boolean = false ;
71
71
72
- private var securityIssue: Boolean = false ; // When SWF parameters contain illegal characters
73
- private var directAccess: Boolean = false ; // When SWF visited directly with no parameters (or when security issue detected)
72
+ private var securityIssue: Boolean = false ; // On direct access and when SWF parameters contain illegal characters
74
73
75
74
private var txLog: TextField ;
76
75
private var debug: Boolean = false ; // Set debug to false for release compile!
77
76
private var localAIRDebug: Boolean = false ; // This is autodetermined by AIR app - leave false!
78
77
79
78
private var traceOut: TraceOut;
80
- //private var outgoing_lc = new LocalConnection ();
79
+
81
80
public function Jplayer () {
82
81
83
82
flash. system. Security . allowDomain ("*" );
@@ -90,6 +89,7 @@ package {
90
89
stage . align = StageAlign . TOP_LEFT ;
91
90
92
91
if (! securityIssue) {
92
+ // The jQuery param is the primary cause of security concerns.
93
93
jQuery = loaderInfo . parameters . jQuery + "('#" + loaderInfo . parameters . id + "').jPlayer" ;
94
94
commonStatus. volume = Number (loaderInfo . parameters . vol);
95
95
commonStatus. muted = loaderInfo . parameters . muted == "true" ;
@@ -128,7 +128,7 @@ package {
128
128
contextMenu = myContextMenu;
129
129
130
130
// Log console for dev compile option: debug
131
- if (debug || directAccess ) {
131
+ if (debug || securityIssue ) {
132
132
txLog = new TextField ();
133
133
txLog. x = 5 ;
134
134
txLog. y = 5 ;
@@ -137,17 +137,13 @@ package {
137
137
txLog. backgroundColor = 0xEEEEFF ;
138
138
txLog. border = true ;
139
139
txLog. background = true ;
140
+ txLog. multiline = true ;
140
141
txLog. text = "jPlayer " + JplayerStatus. VERSION ;
141
142
142
- if (debug ) {
143
- txLog. multiline = true ;
144
- txLog. visible = false ;
145
- } else if (directAccess) {
143
+ if (securityIssue) {
146
144
txLog. visible = true ;
147
- }
148
- if (debug && directAccess) {
149
- txLog. visible = true ;
150
- log ("Direct Access" );
145
+ } else if (debug ) {
146
+ txLog. visible = false ;
151
147
}
152
148
153
149
this . addChild (txLog);
@@ -227,23 +223,29 @@ package {
227
223
}
228
224
}
229
225
private function checkFlashVars (p :Object ):void {
230
- var i: Number = 0 ;
231
- for each (var s: String in p) {
232
- if (illegalChar(s)) {
233
- securityIssue = true ; // Illegal char found
226
+ // Check for direct access. Inspired by mediaelement.js - Also added name to object for non-IE browsers.
227
+ if (ExternalInterface . objectID != null && ExternalInterface . objectID . toString () != "" ) {
228
+ for each (var s: String in p) {
229
+ if (illegalChar(s) || illegalWord(s)) {
230
+ securityIssue = true ; // Found a security concern.
231
+ }
234
232
}
235
- i++;
236
- }
237
- if (i === 0 || securityIssue) {
238
- directAccess = true ;
233
+ } else {
234
+ securityIssue = true ; // Direct access disables the callbacks, which were a security concern.
239
235
}
240
236
}
241
237
private function illegalChar (s :String ):Boolean {
242
- var illegals: String = "' \" ( ) { } * + / \\ < > = document alert" ;
238
+ // A whitelist of accepted chars.
239
+ var validParam: RegExp = / ^[-A-Za-z0-9_.]+$/ ;
240
+ return ! validParam. test (s);
241
+ }
242
+ private function illegalWord (s :String ):Boolean {
243
+ // A blacklist of JavaScript commands that are a security concern.
244
+ var illegals: String = "eval document alert confirm prompt console" ;
243
245
if (Boolean (s)) { // Otherwise exception if parameter null.
244
246
for each (var illegal: String in illegals. split (' ' )) {
245
247
if (s. indexOf (illegal) >= 0 ) {
246
- return true ; // Illegal char found
248
+ return true ; // Illegal word found
247
249
}
248
250
}
249
251
}
@@ -552,7 +554,7 @@ package {
552
554
resizeEntity(videoItem, mediaX, mediaY, mediaWidth, mediaHeight);
553
555
}
554
556
}
555
- if ((debug || directAccess ) && stage . stageWidth > 20 && stage . stageHeight > 20 ) {
557
+ if ((debug || securityIssue ) && stage . stageWidth > 20 && stage . stageHeight > 20 ) {
556
558
txLog. width = stage . stageWidth - 10 ;
557
559
txLog. height = stage . stageHeight - 10 ;
558
560
}
0 commit comments