mirror of
https://github.com/httpie/cli.git
synced 2024-11-24 16:53:35 +01:00
Fix escaping of integer indexes with multiple backslashes (#1288)
This commit is contained in:
parent
7abddfe350
commit
f1ea486025
@ -3,6 +3,10 @@
|
||||
This document records all notable changes to [HTTPie](https://httpie.io).
|
||||
This project adheres to [Semantic Versioning](https://semver.org/).
|
||||
|
||||
## Unreleased
|
||||
|
||||
- Fixed escaping of integer indexes with multiple backslashes in the nested JSON builder. ([#1285](https://github.com/httpie/httpie/issues/1285))
|
||||
|
||||
## [3.0.2](https://github.com/httpie/httpie/compare/3.0.1...3.0.2) (2022-01-24)
|
||||
|
||||
[What’s new in HTTPie for Terminal 3.0 →](https://httpie.io/blog/httpie-3.0.0)
|
||||
|
@ -88,18 +88,18 @@ def tokenize(source: str) -> Iterator[Token]:
|
||||
return None
|
||||
|
||||
value = ''.join(buffer)
|
||||
for variation, kind in [
|
||||
(int, TokenKind.NUMBER),
|
||||
(check_escaped_int, TokenKind.TEXT),
|
||||
]:
|
||||
try:
|
||||
value = variation(value)
|
||||
except ValueError:
|
||||
continue
|
||||
else:
|
||||
break
|
||||
else:
|
||||
kind = TokenKind.TEXT
|
||||
kind = TokenKind.TEXT
|
||||
if not backslashes:
|
||||
for variation, kind in [
|
||||
(int, TokenKind.NUMBER),
|
||||
(check_escaped_int, TokenKind.TEXT),
|
||||
]:
|
||||
try:
|
||||
value = variation(value)
|
||||
except ValueError:
|
||||
continue
|
||||
else:
|
||||
break
|
||||
|
||||
yield Token(
|
||||
kind, value, start=cursor - (len(buffer) + backslashes), end=cursor
|
||||
|
@ -397,6 +397,28 @@ def test_complex_json_arguments_with_non_json(httpbin, request_type, value):
|
||||
'2012': {'x': 2, '[3]': 4},
|
||||
},
|
||||
),
|
||||
(
|
||||
[
|
||||
r'a[\0]:=0',
|
||||
r'a[\\1]:=1',
|
||||
r'a[\\\2]:=2',
|
||||
r'a[\\\\\3]:=3',
|
||||
r'a[-1\\]:=-1',
|
||||
r'a[-2\\\\]:=-2',
|
||||
r'a[\\-3\\\\]:=-3',
|
||||
],
|
||||
{
|
||||
"a": {
|
||||
"0": 0,
|
||||
r"\1": 1,
|
||||
r"\\2": 2,
|
||||
r"\\\3": 3,
|
||||
"-1\\": -1,
|
||||
"-2\\\\": -2,
|
||||
"\\-3\\\\": -3,
|
||||
}
|
||||
}
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_nested_json_syntax(input_json, expected_json, httpbin):
|
||||
|
Loading…
Reference in New Issue
Block a user