[Python-checkins] python/dist/src/Lib/email Message.py, 1.9.6.5, 1.9.6.6

bwarsaw at users.sourceforge.net bwarsaw at users.sourceforge.net
Tue Sep 2 22:14:03 EDT 2003


Update of /cvsroot/python/python/dist/src/Lib/email
In directory sc8-pr-cvs1:/tmp/cvs-serv18894
Modified Files:
 Tag: release22-maint
	Message.py 
Log Message:
A fix for parsing parameters when there are semicolons inside the
quotes. Fixes SF bug #794466, with the essential patch provided by
Stuart D. Gathman. Specifically,
_parseparam(), _get_params_preserve(): Use the parsing function that
takes quotes into account, as given (essentially) in the bug report's
test program.
Backport candidate.
Index: Message.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/email/Message.py,v
retrieving revision 1.9.6.5
retrieving revision 1.9.6.6
diff -C2 -d -r1.9.6.5 -r1.9.6.6
*** Message.py	19 Aug 2003 04:56:46 -0000	1.9.6.5
--- Message.py	3 Sep 2003 04:14:01 -0000	1.9.6.6
***************
*** 59,62 ****
--- 59,79 ----
 return param
 
+ def _parseparam(s):
+ plist = []
+ while s[:1] == ';':
+ s = s[1:]
+ end = s.find(';')
+ while end > 0 and s.count('"', 0, end) % 2:
+ end = s.find(';', end + 1)
+ if end < 0:
+ end = len(s)
+ f = s[:end]
+ if '=' in f:
+ i = f.index('=')
+ f = f[:i].strip().lower() + '=' + f[i+1:].strip()
+ plist.append(f.strip())
+ s = s[end:]
+ return plist
+ 
 
 def _unquotevalue(value):
***************
*** 526,530 ****
 return failobj
 params = []
! for p in paramre.split(value):
 try:
 name, val = p.split('=', 1)
--- 543,547 ----
 return failobj
 params = []
! for p in _parseparam(';' + value):
 try:
 name, val = p.split('=', 1)


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /