mirror of
https://github.com/httpie/cli.git
synced 2025-02-17 18:10:50 +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 document records all notable changes to [HTTPie](https://httpie.io).
|
||||||
This project adheres to [Semantic Versioning](https://semver.org/).
|
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)
|
## [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)
|
[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
|
return None
|
||||||
|
|
||||||
value = ''.join(buffer)
|
value = ''.join(buffer)
|
||||||
for variation, kind in [
|
kind = TokenKind.TEXT
|
||||||
(int, TokenKind.NUMBER),
|
if not backslashes:
|
||||||
(check_escaped_int, TokenKind.TEXT),
|
for variation, kind in [
|
||||||
]:
|
(int, TokenKind.NUMBER),
|
||||||
try:
|
(check_escaped_int, TokenKind.TEXT),
|
||||||
value = variation(value)
|
]:
|
||||||
except ValueError:
|
try:
|
||||||
continue
|
value = variation(value)
|
||||||
else:
|
except ValueError:
|
||||||
break
|
continue
|
||||||
else:
|
else:
|
||||||
kind = TokenKind.TEXT
|
break
|
||||||
|
|
||||||
yield Token(
|
yield Token(
|
||||||
kind, value, start=cursor - (len(buffer) + backslashes), end=cursor
|
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},
|
'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):
|
def test_nested_json_syntax(input_json, expected_json, httpbin):
|
||||||
|
Loading…
Reference in New Issue
Block a user