Skip to content

Commit

Permalink
fix the copy-paste error from r60 where it used ; instead of , in par…
Browse files Browse the repository at this point in the history
…sing comma headers such as authentication related
  • Loading branch information
theintencity committed Apr 13, 2012
1 parent f721a69 commit cff51ad
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/std/rfc3261.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,27 +85,31 @@ def _parse(self, value, name):
if name in _comma:
self.authMethod, sep, rest = value.strip().partition(' ')
if rest:
self._parseParams(rest)
self._parseParams(rest, delimiter=',')
# for n,v in map(lambda x: x.strip().split('='), rest.split(',') if rest else []):
# self.__dict__[n.lower().strip()] = _unquote(v.strip())
elif name == 'cseq':
n, sep, self.method = map(lambda x: x.strip(), value.partition(' '))
self.number = int(n); value = n + ' ' + self.method
return value

def _parseParams(self, rest):
def _parseParams(self, rest, delimiter=';'):
try:
length, index = len(rest), 0
while index < length:
sep1 = rest.find('=', index)
sep2 = rest.find(';', index)
sep2 = rest.find(delimiter, index)
if sep2 < 0: sep2 = length # next parameter
n = v = ''
if sep1 >= 0 and sep1 < sep2: # parse "a=b;..." or "a=b"
n = rest[index:sep1].lower().strip()
if rest[sep1+1] == '"': sep1 += 1; sep2 = rest.find('"', sep1+2)
v = rest[sep1+1:sep2].strip()
index = sep2+1
if rest[sep1+1] == '"': sep1 += 1; sep2 = rest.find('"', sep1+1)
if sep2 >= 0:
v = rest[sep1+1:sep2].strip()
index = sep2+2
else:
v = rest[sep1+1:].strip()
index = length
elif sep1 < 0 or sep1 >= 0 and sep1 > sep2: # parse "a" or "a;b=c" or ";b"
n, index = rest[index:sep2].lower().strip(), sep2+1
else: break
Expand Down

0 comments on commit cff51ad

Please sign in to comment.