From 3cbb81429310774da19da7c499574c60bf5c83ba Mon Sep 17 00:00:00 2001
From: Yusei Tahara <yusei@nexedi.com>
Date: Tue, 2 Sep 2008 11:40:13 +0000
Subject: [PATCH] Use standard_b64encode, standard_b64decode instead of
 encodestring, decodestring.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@23339 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5Type/patches/CookieCrumbler.py | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/product/ERP5Type/patches/CookieCrumbler.py b/product/ERP5Type/patches/CookieCrumbler.py
index 4e3563a591..cbcecb1ed0 100644
--- a/product/ERP5Type/patches/CookieCrumbler.py
+++ b/product/ERP5Type/patches/CookieCrumbler.py
@@ -34,7 +34,7 @@ ATTEMPT_NONE = 0       # No attempt at authentication
 ATTEMPT_LOGIN = 1      # Attempt to log in
 ATTEMPT_RESUME = 2     # Attempt to resume session
 
-from base64 import encodestring, decodestring
+from base64 import standard_b64encode, standard_b64decode
 from DateTime import DateTime
 
 class PatchedCookieCrumbler(CookieCrumbler):
@@ -99,8 +99,7 @@ def modifyRequest(self, req, resp):
       attempt = ATTEMPT_LOGIN
       name = req[self.name_cookie]
       pw = req[self.pw_cookie]
-      #ac = encodestring('%s:%s' % (name, pw)).rstrip() => changed for remove all newlines
-      ac = encodestring('%s:%s' % (name, pw)).replace('\012','')
+      ac = standard_b64encode('%s:%s' % (name, pw))
       self._setAuthHeader(ac, req, resp)
       if req.get(self.persist_cookie, 0):
         # Persist the user name (but not the pw or session)
@@ -124,7 +123,7 @@ def modifyRequest(self, req, resp):
       ac = unquote(req[self.auth_cookie])
       if ac and ac != 'deleted':
         try:
-          decodestring(ac)
+          standard_b64decode(ac)
         except:
           # Not a valid auth header.
           pass
@@ -144,8 +143,7 @@ CookieCrumbler.modifyRequest = modifyRequest
 
 
 def credentialsChanged(self, user, name, pw):
-  #ac = encodestring('%s:%s' % (name, pw)).rstrip() => changed for remove all newlines
-  ac = encodestring('%s:%s' % (name, pw)).replace('\012','')
+  ac = standard_b64encode('%s:%s' % (name, pw))
   method = self.getCookieMethod( 'setAuthCookie'
                                  , self.defaultSetAuthCookie )
   resp = self.REQUEST['RESPONSE']
-- 
2.30.9