| 1037 | # data loss, this function errs on the conservative side. |
| 1038 | @staticmethod |
| 1039 | def lookslikehtml(s): |
| 1040 | # must have a close tag or an entity reference to qualify |
| 1041 | if not (re.search(r'</(\w+)>',s) or re.search("&#?\w+;",s)): |
| 1042 | return |
| 1043 | |
| 1044 | # all tags must be in a restricted subset of valid HTML tags |
| 1045 | if filter(lambda t: t.lower() not in _HTMLSanitizer.acceptable_elements, |
| 1046 | re.findall(r'</?(\w+)',s)): |
| 1047 | return |
| 1048 | |
| 1049 | # all entities must have been defined as valid HTML entities |
| 1050 | if filter(lambda e: e not in entitydefs.keys(), re.findall(r'&(\w+);', s)): |
| 1051 | return |
| 1052 | |
| 1053 | return 1 |
| 1054 | |
| 1055 | def _mapToStandardPrefix(self, name): |
| 1056 | colonpos = name.find(':') |