CVS: tmda/TMDA Address.py,1.4,1.5 ChangeLog,1.278,1.279

Timothy Legant <[email protected]>
Newsgroups gmane.mail.spam.tmda.cvs
Message-ID <[email protected]>
Update of /cvsroot/tmda/tmda/TMDA
In directory sc8-pr-cvs1:/tmp/cvs-serv5594/TMDA

Modified Files:
	Address.py ChangeLog 
Log Message:
tmda-check-address: Imported Defaults.py.  Fixed some unusual code
that apparently doesn't work in later versions of Python (different
exceptions are raised than were caught).  Added new function
formattime().

Address.py: Fixed ConfirmAddress, removed formatting code from
DatedAddress.timestamp().



Index: Address.py
===================================================================
RCS file: /cvsroot/tmda/tmda/TMDA/Address.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Address.py	29 Apr 2003 18:29:47 -0000	1.4
+++ Address.py	25 Jun 2003 05:29:13 -0000	1.5
@@ -85,30 +85,32 @@
 class ConfirmAddress(TaggedAddress):
     def __init__(self, address=''):
         TaggedAddress.__init__(self, address)
+        self.keyword = 'accept'
 
-    def create(self, base, timestamp, pid, keyword):
+    def create(self, base, timestamp, pid, keyword='accept'):
         if Defaults.CONFIRM_ADDRESS:
             base = Defaults.CONFIRM_ADDRESS
         elif not base:
             base = self.base()
+        self.keyword = keyword
         (dummy, local, domain) = _split(str(base))
         cookie = Cookie.make_confirm_cookie(int(timestamp), pid, keyword)
-        self.local_parts = [ local, Defaults.TAGS_CONFIRM[0].lower(), keyword + '.' + cookie ]
+        self.local_parts = [ local, Defaults.TAGS_CONFIRM[0].lower(), cookie ]
         tagged_local = Defaults.RECIPIENT_DELIMITER.join(self.local_parts)
         self.address = tagged_local + '@' + domain
         return self
 
     def verify(self, dummy=''):
         try:
-            (keyword, timestamp, pid, hmac) = self.local_parts[-1].split('.')
-            try_hmac = Cookie.confirmationmac(timestamp, pid, keyword)
+            (timestamp, pid, hmac) = self.local_parts[-1].split('.')
+            try_hmac = Cookie.confirmationmac(timestamp, pid, self.keyword)
             if try_hmac != hmac:
                 raise BadCryptoError, "Invalid cryptographic tag."
         except ValueError:
             raise BadCryptoError, "Invalid cryptographic tag format."
 
     def keyword(self):
-        return self.local_parts[-1].split('.')[0]
+        return self.keyword
 
     def timestamp(self):
         return self.local_parts[-1].split('.')[1]
@@ -145,19 +147,8 @@
         except ValueError:
             raise BadCryptoError, "Invalid cryptographic tag format."
 
-    def timestamp(self, prettyprint = 0, localtime = 0):
-        expires = self.local_parts[-1].split('.')[0]
-
-        if not prettyprint:
-            return expires
-
-        expires = int(expires)
-        if localtime:
-            local_tz = time.strftime("%Z", time.localtime(expires))
-            expires_str = time.asctime(time.localtime(expires)) + ' ' + local_tz
-        else:
-            expires_str = time.asctime(time.gmtime(expires)) + ' UTC'
-        return expires_str
+    def timestamp(self):
+        return self.local_parts[-1].split('.')[0]
 
     def hmac(self):
         return self.local_parts[-1].split('.')[1]
@@ -179,6 +170,8 @@
 
     def verify(self, dummy=''):
         parts = self.local_parts[-1].split('.')
+        # Not necessary anymore, since '.', among other chars, is
+        # replaced by '?' in Cookie.make_keywordmac().
         keyword = '.'.join(parts[:-1])
         if not keyword:
             raise BadCryptoError, "Invalid cryptographic tag format."

Index: ChangeLog
===================================================================
RCS file: /cvsroot/tmda/tmda/TMDA/ChangeLog,v
retrieving revision 1.278
retrieving revision 1.279
diff -u -r1.278 -r1.279
--- ChangeLog	21 Jun 2003 02:30:17 -0000	1.278
+++ ChangeLog	25 Jun 2003 05:29:13 -0000	1.279
@@ -1,3 +1,8 @@
+2003-06-25  Tim Legant  <[email protected]>
+
+	* Address.py: Fixed ConfirmAddress, removed formatting code from
+	DatedAddress.timestamp().
+
 2003-06-20  Gre7g Luterman  <[email protected]>
 
 	* Fixed a bug in the LDAP code found by Chet McNeill.

_______________________________________
tmda-cvs mailing list
http://tmda.net/lists/listinfo/tmda-cvs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.