*** /import/Python-2.4.1/Lib/email/Generator.py Sat Oct 2 20:16:18 2004 --- ./Generator.py Sat Jul 23 09:52:45 2005 *************** *** 210,216 **** # Now make sure the boundary we've selected doesn't appear in any of # the message texts. - alltext = NL.join(msgtexts) # BAW: What about boundaries that are wrapped in double-quotes? ! boundary = msg.get_boundary(failobj=_make_boundary(alltext)) # If we had to calculate a new boundary because the body text # contained that string, set the new boundary. We don't do it --- 210,215 ---- # Now make sure the boundary we've selected doesn't appear in any of # the message texts. # BAW: What about boundaries that are wrapped in double-quotes? ! boundary = _get_or_make_boundary(msg, lambda: NL.join(msgtexts)) # If we had to calculate a new boundary because the body text # contained that string, set the new boundary. We don't do it *************** *** 338,346 **** _fmt = '%%0%dd' % _width ! def _make_boundary(text=None): ! # Craft a random boundary. If text is given, ensure that the chosen ! # boundary doesn't appear in the text. token = random.randrange(sys.maxint) ! boundary = ('=' * 15) + (_fmt % token) + '==' if text is None: return boundary --- 337,350 ---- _fmt = '%%0%dd' % _width ! def _get_or_make_boundary(msg, textproc=lambda: None): ! # Get the boundary of msg. If it doesn't have one, craft a random ! # boundary. If text is given, ensure that the chosen boundary doesn't ! # appear in the text. We delay constructing the text until we're sure ! # we need it. ! missing = [] ! boundary = msg.get_boundary(missing) ! if boundary is not missing: return boundary token = random.randrange(sys.maxint) ! boundary, text = ('=' * 15) + (_fmt % token) + '==', textproc() if text is None: return boundary *************** *** 348,351 **** --- 352,357 ---- counter = 0 while True: + # Avoid the expense of constructing the RE if possible. + if text.find(b) < 0: break cre = re.compile('^--' + re.escape(b) + '(--)?$', re.MULTILINE) if not cre.search(text):