1
0
mirror of https://github.com/httpie/cli.git synced 2025-06-08 23:46:33 +02:00
This commit is contained in:
Jakub Roztocil 2014-09-16 12:36:14 +02:00
parent 2078ece95a
commit c301305a59

View File

@ -460,16 +460,15 @@ class KeyValueArgType(object):
=> ['foo', Escaped('='), 'bar', Escaped('\\'), 'baz'] => ['foo', Escaped('='), 'bar', Escaped('\\'), 'baz']
""" """
backslash = '\\'
tokens = [''] tokens = ['']
characters = iter(string) characters = iter(string)
for char in characters: for char in characters:
if char == backslash: if char == '\\':
next_char = next(characters, '') char = next(characters, '')
if next_char in self.special_characters: if char not in self.special_characters:
tokens.extend([Escaped(next_char), '']) tokens[-1] += '\\' + char
else: else:
tokens[-1] += char + next_char tokens.extend([Escaped(char), ''])
else: else:
tokens[-1] += char tokens[-1] += char
return tokens return tokens