[or-cvs] r16923: {weather} Fix weather.py to return proper random strings that will not (weather/trunk)

ioerror at seul.org ioerror at seul.org
Wed Sep 17 23:11:58 UTC 2008


Author: ioerror
Date: 2008-09-17 19:11:58 -0400 (Wed, 17 Sep 2008)
New Revision: 16923

Modified:
   weather/trunk/weather.py
Log:
Fix weather.py to return proper random strings that will not break karsten's email client.


Modified: weather/trunk/weather.py
===================================================================
--- weather/trunk/weather.py	2008-09-17 22:58:52 UTC (rev 16922)
+++ weather/trunk/weather.py	2008-09-17 23:11:58 UTC (rev 16923)
@@ -83,8 +83,12 @@
   sub.sync()
       
 def randstring():
+  # This is where we sometimes return '-' and we shouldn't
   "Produce a random alphanumeric string for authentication"
-  return base64.urlsafe_b64encode(os.urandom(18))[:-1]
+  theory = base64.urlsafe_b64encode(os.urandom(18))[:-1]
+  if theory[-1] == "-":    # some email clients don't like URLs ending in -
+    theory[-1] = 'x'
+  return theory
 
 subscribe_text = \
 """Dear human, this is the Tor Weather Report system.  



More information about the tor-commits mailing list