Skip to content

Commit e2d1de1

Browse files
committed
Fix: Correctly unescape key/value parts in KeyValueArgType
1 parent b12fc15 commit e2d1de1

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

httpie/cli/argtypes.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,16 +95,17 @@ def __call__(self, s: str) -> KeyValueArg:
9595
key_part, value_part = token.split(sep, 1)
9696

9797
# The key is composed of:
98-
# 1. Any preceding tokens (unescaped by str(t) in join)
99-
# 2. The key part of the current token (re-tokenize to
100-
# handle internal escapes correctly)
101-
key_tokens = tokens[:i] + self.tokenize(key_part)
98+
# 1. Any preceding tokens (already Escaped or regular strings)
99+
# 2. The key part of the current token (re-tokenize to catch internal escapes)
100+
key_tokens = tokens[:i]
101+
key_tokens.extend(self.tokenize(key_part))
102102
key = ''.join(str(t) for t in key_tokens)
103103

104104
# The value is composed of:
105-
# 1. The value part of the current token (re-tokenize)
106-
# 2. Any succeeding tokens (unescaped by str(t) in join)
107-
value_tokens = self.tokenize(value_part) + tokens[i + 1:]
105+
# 1. The value part of the current token (re-tokenize to catch internal escapes)
106+
# 2. Any succeeding tokens
107+
value_tokens = self.tokenize(value_part)
108+
value_tokens.extend(tokens[i + 1:])
108109
value = ''.join(str(t) for t in value_tokens)
109110

110111
break

0 commit comments

Comments
 (0)