diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2015-05-19 07:09:27 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-05-19 07:09:27 (GMT) |
commit | 49f2ccf83dfd9f111caddeb85cbd72d1fab84a92 (patch) | |
tree | bdcb355e28314d9f1c4136a895b4536339681fc3 /Lib/email/utils.py | |
parent | 23120090f5efe2627ecb56384d5f117893d748a5 (diff) | |
download | cpython-49f2ccf83dfd9f111caddeb85cbd72d1fab84a92.zip cpython-49f2ccf83dfd9f111caddeb85cbd72d1fab84a92.tar.gz cpython-49f2ccf83dfd9f111caddeb85cbd72d1fab84a92.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/utils.py')
-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 c976021..ac13f49 100644 --- a/Lib/email/utils.py +++ b/Lib/email/utils.py @@ -177,21 +177,20 @@ def formatdate(timeval=None, localtime=False, usegmt=False): def make_msgid(idstring=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. """ - 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 idhost = socket.getfqdn() - msgid = '<%s.%s.%s%s@%s>' % (utcdate, pid, randint, idstring, idhost) + msgid = '<%d.%d.%d%s@%s>' % (timeval, pid, randint, idstring, idhost) return msgid |