[Nym3-commit] r497 - trunk/nymbaron/Server

zax at conuropsis.org zax at conuropsis.org
Tue Mar 21 01:56:36 CET 2006


Author: zax
Date: 2006-03-21 01:56:34 +0100 (Tue, 21 Mar 2006)
New Revision: 497

Modified:
   trunk/nymbaron/Server/Main.py
Log:
Improve Base64 regex check. We don't want to rely on surrounding text to identify the payload.


Modified: trunk/nymbaron/Server/Main.py
===================================================================
--- trunk/nymbaron/Server/Main.py	2006-03-20 16:46:19 UTC (rev 496)
+++ trunk/nymbaron/Server/Main.py	2006-03-21 00:56:34 UTC (rev 497)
@@ -134,9 +134,12 @@
     """ Base64 payload should consist of nothing but text and newline
     characters.  Check for this and return the payload if it matches.
     Otherwise, return False"""
-    m = re.search('binary\n\n([\S\n]+)\n-{5}END', msg, re.S)
+    #TODO: I would like this regex to be a little stronger although it works
+    # in all the tests I've done.  Better too weak and generate an exception
+    # than too strong and corrupt a message.
+    m = re.search('(^[\w+/=]{1,76}\n){2,}', msg, re.M)
     if m:
-        return m.group(1)
+        return m.group(0)
     return False
 
 def processIncoming(localpart, msg):



More information about the Nym3-commit mailing list