Permalink
Browse files

MDL-30876 filter_mediaplugin Wrapping the style sheets access with tr…

…y & catch

Conflicts:

	lib/javascript-static.js
  • Loading branch information...
1 parent 6039dc5 commit 8f80180de6955e836b6eb6837e34b90566c8c070 @dmonllao dmonllao committed with Sam Hemelryk Dec 22, 2011
Showing with 19 additions and 7 deletions.
  1. +19 −7 lib/javascript-static.js
View
26 lib/javascript-static.js
@@ -1771,15 +1771,27 @@ M.util.load_flowplayer = function() {
var rule;
for (var j=0; j < document.styleSheets.length; j++) {
- if (typeof (document.styleSheets[j].rules) != 'undefined') {
- var allrules = document.styleSheets[j].rules;
- } else if (typeof (document.styleSheets[j].cssRules) != 'undefined') {
- var allrules = document.styleSheets[j].cssRules;
- } else {
- // why??
+
+ // To avoid javascript security violation accessing cross domain stylesheets
+ var allrules = false;
+ try {
+ if (typeof (document.styleSheets[j].rules) != 'undefined') {
+ allrules = document.styleSheets[j].rules;
+ } else if (typeof (document.styleSheets[j].cssRules) != 'undefined') {
+ allrules = document.styleSheets[j].cssRules;
+ } else {
+ // why??
+ continue;
+ }
+ } catch (e) {
continue;
}
- if (!allrules) continue;
+
+ // On cross domain style sheets Chrome V8 allows access to rules but returns null
+ if (!allrules) {
+ continue;
+ }
+
for(var i=0; i<allrules.length; i++) {
rule = '';
if (/^\.mp3flowplayer_.*Color$/.test(allrules[i].selectorText)) {

0 comments on commit 8f80180

Please sign in to comment.