[BUGFIX] RTE: Importing google webfonts breaks style sheet parsing 64/21864/2
authorStanislas Rolland <typo3@sjbr.ca>
Wed, 3 Jul 2013 22:45:12 +0000 (18:45 -0400)
committerStanislas Rolland <typo3@sjbr.ca>
Wed, 3 Jul 2013 23:52:52 +0000 (01:52 +0200)
Problem: Firefox raises a security error because the file is not in the
same domain as the executing script. Probably a Firefox bug since the
file certainly has adequate headers: the font are indeed displayed in
the RTE.

Solution: Since the Webfont style sheet does not contain any css rules
anyways, we will catch the error, and if it is a security error, log it
to the Javascript console (or Firebug) and silently continue. Re-throw
any other type of error.

Resolves: #49648
Releases: 4.5, 4.7, 6.0, 6.1, 6.2
Change-Id: I225152ad5d84de50f29d3830be6f1f3e10f249c8
Reviewed-on: https://review.typo3.org/21864
Reviewed-by: Stanislas Rolland
Tested-by: Stanislas Rolland
typo3/sysext/rtehtmlarea/htmlarea/htmlarea.js

index af9e294..edace68 100644 (file)
@@ -3776,8 +3776,17 @@ HTMLArea.CSS.Parser = Ext.extend(Ext.util.Observable, {
                                this.parseSelectorText(cssRules[rule].selectorText);
                        } else {
                                        // Import rule
-                               if (cssRules[rule].styleSheet && cssRules[rule].styleSheet.cssRules) {
-                                       this.parseRules(cssRules[rule].styleSheet.cssRules);
+                               try {
+                                       if (cssRules[rule].styleSheet && cssRules[rule].styleSheet.cssRules) {
+                                                       this.parseRules(cssRules[rule].styleSheet.cssRules);
+                                       }
+                               } catch (e) {
+                                       if (/Security/i.test(e)) {
+                                               // If this is a security error, silently log the error and continue parsing
+                                               this.editor.appendToLog('HTMLArea.CSS.Parser', 'parseRules', 'A security error occurred. Make sure all stylesheets are accessed from the same domain/subdomain and using the same protocol as the current script.', 'error');
+                                       } else {
+                                               throw e;
+                                       }
                                }
                                        // Media rule
                                if (cssRules[rule].cssRules) {