Commit a49846b7 authored by Barry Warsaw's avatar Barry Warsaw

_make_boundary(): Fix for SF bug #745478, broken boundary calculation

in some locales.  This code simplifies the boundary algorithm to use
randint() which is what we wanted anyway.

Bump package version to 2.5.3.

Backport candidate for Python 2.2.3
parent ef8c259c
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
""" """
import re import re
import sys
import time import time
import locale import locale
import random import random
...@@ -356,11 +357,14 @@ class DecodedGenerator(Generator): ...@@ -356,11 +357,14 @@ class DecodedGenerator(Generator):
# Helper # Helper
_width = len(repr(sys.maxint-1))
_fmt = '%%0%dd' % _width
def _make_boundary(text=None): def _make_boundary(text=None):
# Craft a random boundary. If text is given, ensure that the chosen # Craft a random boundary. If text is given, ensure that the chosen
# boundary doesn't appear in the text. # boundary doesn't appear in the text.
dp = locale.localeconv().get('decimal_point', '.') token = random.randint(0, sys.maxint-1)
boundary = ('=' * 15) + repr(random.random()).split(dp)[1] + '==' boundary = ('=' * 15) + (_fmt % token) + '=='
if text is None: if text is None:
return boundary return boundary
b = boundary b = boundary
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
"""A package for parsing, handling, and generating email messages. """A package for parsing, handling, and generating email messages.
""" """
__version__ = '2.5.2' __version__ = '2.5.3'
__all__ = [ __all__ = [
'base64MIME', 'base64MIME',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment