| 2844 | return ' '.join(clean) |
| 2845 | |
| 2846 | def parse_comment(self, i, report=1): |
| 2847 | ret = _BaseHTMLProcessor.parse_comment(self, i, report) |
| 2848 | if ret >= 0: |
| 2849 | return ret |
| 2850 | # if ret == -1, this may be a malicious attempt to circumvent |
| 2851 | # sanitization, or a page-destroying unclosed comment |
| 2852 | match = re.compile(r'--[^>]*>').search(self.rawdata, i+4) |
| 2853 | if match: |
| 2854 | return match.end() |
| 2855 | # unclosed comment; deliberately fail to handle_data() |
| 2856 | return len(self.rawdata) |
| 2857 | |
| 2858 | |
| 2859 | def _sanitizeHTML(htmlSource, encoding, _type): |