(self, style)
| 2815 | _BaseHTMLProcessor.handle_data(self, text) |
| 2816 | |
| 2817 | def sanitize_style(self, style): |
| 2818 | # disallow urls |
| 2819 | style=re.compile('url\s*\(\s*[^\s)]+?\s*\)\s*').sub(' ',style) |
| 2820 | |
| 2821 | # gauntlet |
| 2822 | if not re.match("""^([:,;#%.\sa-zA-Z0-9!]|\w-\w|'[\s\w]+'|"[\s\w]+"|\([\d,\s]+\))*$""", style): |
| 2823 | return '' |
| 2824 | # This replaced a regexp that used re.match and was prone to pathological back-tracking. |
| 2825 | if re.sub("\s*[-\w]+\s*:\s*[^:;]*;?", '', style).strip(): |
| 2826 | return '' |
| 2827 | |
| 2828 | clean = [] |
| 2829 | for prop,value in re.findall("([-\w]+)\s*:\s*([^:;]*)",style): |
| 2830 | if not value: |
| 2831 | continue |
| 2832 | if prop.lower() in self.acceptable_css_properties: |
| 2833 | clean.append(prop + ': ' + value + ';') |
| 2834 | elif prop.split('-')[0].lower() in ['background','border','margin','padding']: |
| 2835 | for keyword in value.split(): |
| 2836 | if not keyword in self.acceptable_css_keywords and \ |
| 2837 | not self.valid_css_values.match(keyword): |
| 2838 | break |
| 2839 | else: |
| 2840 | clean.append(prop + ': ' + value + ';') |
| 2841 | elif self.svgOK and prop.lower() in self.acceptable_svg_properties: |
| 2842 | clean.append(prop + ': ' + value + ';') |
| 2843 | |
| 2844 | return ' '.join(clean) |
| 2845 | |
| 2846 | def parse_comment(self, i, report=1): |
| 2847 | ret = _BaseHTMLProcessor.parse_comment(self, i, report) |
no test coverage detected