diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2015-05-19 07:10:15 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-05-19 07:10:15 (GMT) |
commit | 6baa0a53b05d580d21d260c5d7d6ee2d3ff005ee (patch) | |
tree | 064b703fb4ba97f7ee79880b1b6e5b4fb6f9a6a1 /Lib/email | |
parent | 8687275358a9267c5ea7dcd4ce6a4cbd0f91f541 (diff) | |
parent | ae760c0a2ccd5557bfd915c947dfbcd3ed64fd60 (diff) | |
download | cpython-6baa0a53b05d580d21d260c5d7d6ee2d3ff005ee.zip cpython-6baa0a53b05d580d21d260c5d7d6ee2d3ff005ee.tar.gz cpython-6baa0a53b05d580d21d260c5d7d6ee2d3ff005ee.tar.bz2 |
Issue #6598: Increased time precision and random number range in
email.utils.make_msgid() to strengthen the uniqueness of the message ID.
Diffstat (limited to 'Lib/email')
-rw-r--r-- | Lib/email/utils.py | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/Lib/email/utils.py b/Lib/email/utils.py index cacb9b1..317fdfa 100644 --- a/Lib/email/utils.py +++ b/Lib/email/utils.py @@ -202,24 +202,23 @@ def format_datetime(dt, usegmt=False): def make_msgid(idstring=None, domain=None): """Returns a string suitable for RFC 2822 compliant Message-ID, e.g: - <20020201195627.33539.96671@nightshade.la.mastaler.com> + <142480216486.20800.16526388040877946887@nightshade.la.mastaler.com> Optional idstring if given is a string used to strengthen the uniqueness of the message id. Optional domain if given provides the portion of the message id after the '@'. It defaults to the locally defined hostname. """ - timeval = time.time() - utcdate = time.strftime('%Y%m%d%H%M%S', time.gmtime(timeval)) + timeval = int(time.time()*100) pid = os.getpid() - randint = random.randrange(100000) + randint = random.getrandbits(64) if idstring is None: idstring = '' else: idstring = '.' + idstring if domain is None: domain = socket.getfqdn() - msgid = '<%s.%s.%s%s@%s>' % (utcdate, pid, randint, idstring, domain) + msgid = '<%d.%d.%d%s@%s>' % (timeval, pid, randint, idstring, domain) return msgid |