| 231 | |
| 232 | if sgmllib.endbracket.search(' <').start(0): |
| 233 | class EndBracketRegEx: |
| 234 | def __init__(self): |
| 235 | # Overriding the built-in sgmllib.endbracket regex allows the |
| 236 | # parser to find angle brackets embedded in element attributes. |
| 237 | self.endbracket = re.compile('''([^'"<>]|"[^"]*"(?=>|/|\s|\w+=)|'[^']*'(?=>|/|\s|\w+=))*(?=[<>])|.*?(?=[<>])''') |
| 238 | def search(self,string,index=0): |
| 239 | match = self.endbracket.match(string,index) |
| 240 | if match is not None: |
| 241 | # Returning a new object in the calling thread's context |
| 242 | # resolves a thread-safety. |
| 243 | return EndBracketMatch(match) |
| 244 | return None |
| 245 | class EndBracketMatch: |
| 246 | def __init__(self, match): |
| 247 | self.match = match |