CVS: tmda/TMDA ChangeLog,1.286,1.287 Util.py,1.103,1.104

"Jason R. Mastaler" <[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-serv23950/TMDA

Modified Files:
	ChangeLog Util.py 
Log Message:
Bugfix from Ed Blackman.  When email address lines are read from
filter textfiles in Util.file_to_list, the lines are stripped of
inline comments (the line "[email protected] # Joe Foo" becomes
"[email protected]").

However, when the filter textfiles are examined in
Util.append_to_file, to see if the string being appended already
exists, the lines aren't stripped of inline comments before checking
to see if they're identical.  Since an address with a comment won't be
identical to the same address without one, the address gets added a
second time.

The following patch fixes what I believe is inconsistent behavior by
stripping inline comments from both strings in append_to_file, to
ensure that the same address won't get added twice.


Index: ChangeLog
===================================================================
RCS file: /cvsroot/tmda/tmda/TMDA/ChangeLog,v
retrieving revision 1.286
retrieving revision 1.287
diff -u -r1.286 -r1.287
--- ChangeLog	21 Aug 2003 19:18:31 -0000	1.286
+++ ChangeLog	22 Sep 2003 23:00:21 -0000	1.287
@@ -1,3 +1,8 @@
+2003-09-22  Jason R. Mastaler  <[email protected]>
+
+	* Util.py (append_to_file): Strip inline comments before checking
+	for duplicate entries.
+
 2003-08-21  Tim Legant  <[email protected]>
 
 	* Pending.py (initQueue): After reading message list from stdin,

Index: Util.py
===================================================================
RCS file: /cvsroot/tmda/tmda/TMDA/Util.py,v
retrieving revision 1.103
retrieving revision 1.104
diff -u -r1.103 -r1.104
--- Util.py	1 Aug 2003 07:22:53 -0000	1.103
+++ Util.py	22 Sep 2003 23:00:21 -0000	1.104
@@ -412,16 +412,18 @@
     """Append a string to a text file if it isn't already in there."""
     if os.path.exists(fullpathname):
         for line in fileinput.input(fullpathname):
-            line = string.lower(string.strip(line))
+            line = line.strip().lower()
             # Comment or blank line?
             if line == '' or line[0] in '#':
                 continue
             else:
-                if string.lower(string.strip(str)) == line:
+                line = line.expandtabs().split('#')[0].strip()
+                bare = str.expandtabs().split('#')[0].strip()
+                if bare.lower() == line:
                     fileinput.close()
                     return 0
     file = open(fullpathname, 'a+')
-    file.write(string.strip(str) + '\n')
+    file.write(str.strip() + '\n')
     file.close()
 
 

_______________________________________
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.