Index: TwistedWords-0.5.0/twisted/words/xish/domish.py =================================================================== --- TwistedWords-0.5.0/twisted/words/xish/domish.py (revision 5107) +++ TwistedWords-0.5.0/twisted/words/xish/domish.py (revision 5108) @@ -168,8 +168,7 @@ self.prefixStack.pop() SerializerClass = _ListSerializer - -def escapeToXml(text, isattrib = 0): +def escapeToXml(text, isattrib = 0,cache = {}): """ Escape text to proper XML form, per section 2.3 in the XML specification. @type text: L{str} @@ -179,12 +178,21 @@ @param isattrib: Triggers escaping of characters necessary for use as attribute values """ + if len(cache) > 1000000: + cache.clear() + + try: + return cache[text] + except: + pass + itext = text text = text.replace("&", "&") text = text.replace("<", "<") text = text.replace(">", ">") if isattrib == 1: text = text.replace("'", "'") text = text.replace("\"", """) + cache[itext] = text return text def unescapeFromXml(text):