r111842 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r111841‎ | r111842 | r111843 >
Date:20:16, 18 February 2012
Author:au
Status:ok
Tags:
Comment:
* Rudimentary CSS validation; +4 tests pass. (Bug 2304, 3244).
Modified paths:
  • /trunk/extensions/VisualEditor/modules/parser/ext.core.Sanitizer.js (modified) (history)

Diff [purge]

Index: trunk/extensions/VisualEditor/modules/parser/ext.core.Sanitizer.js
@@ -99,12 +99,25 @@
100100 if ( kv.v.constructor === Array ) {
101101 kv.v = this.manager.env.tokensToString ( kv.v );
102102 }
 103+ if ( kv.k === 'style' ) {
 104+ kv.v = this.checkCss(kv.v);
 105+ }
103106 }
104107 }
105108 // XXX: Validate attributes
106109 return { token: token };
107110 };
108111
 112+Sanitizer.prototype.checkCss = function ( value ) {
 113+ if (/[\000-\010\016-\037\177]/.test(value)) {
 114+ return '/* invalid control char */';
 115+ }
 116+ if (/expression|filter\s*:|accelerator\s*:|url\s*\(/i.test(value)) {
 117+ return '/* insecure input */';
 118+ }
 119+ return value;
 120+};
 121+
109122 if (typeof module == "object") {
110123 module.exports.Sanitizer = Sanitizer;
111124 }

Sign-offs

UserFlagDate
GWickeinspected21:21, 20 February 2012
GWicketested21:21, 20 February 2012

Status & tagging log