From 1d05efe34b951836717392d5f6900f3841fa2048 Mon Sep 17 00:00:00 2001 From: ketralnis Date: Sun, 26 Apr 2009 00:34:34 -0700 Subject: [PATCH] Disallow backslashes in stylesheets. Work-around for bug in cssutils related to greedy parsing of them. --- r2/r2/lib/cssfilter.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/r2/r2/lib/cssfilter.py b/r2/r2/lib/cssfilter.py index fc6450e6c..0f08a6c65 100644 --- a/r2/r2/lib/cssfilter.py +++ b/r2/r2/lib/cssfilter.py @@ -240,7 +240,7 @@ def validate_css(string): return ('',ValidationReport()) report = ValidationReport(string) - + # avoid a very expensive parse max_size_kb = 100; if len(string) > max_size_kb * 1024: @@ -248,6 +248,9 @@ def validate_css(string): % dict (max_size = max_size_kb)))) return (string, report) + if '\\' in string: + report.append(ValidationError(_("if you need backslashes, you're doing it wrong"))) + try: parsed = p.parseString(string) except DOMException,e: