Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Escaping backslashes in nested json keys #1285

Closed
2 tasks done
ducaale opened this issue Jan 29, 2022 · 0 comments · Fixed by #1288
Closed
2 tasks done

Escaping backslashes in nested json keys #1285

ducaale opened this issue Jan 29, 2022 · 0 comments · Fixed by #1288
Assignees
Labels
bug Something isn't working

Comments

@ducaale
Copy link

ducaale commented Jan 29, 2022

Checklist

  • I've searched for similar issues.
  • I'm using the latest version of HTTPie.

Minimal reproduction code and steps

Run http httpbin.org/post 'foo[\\8]=bar' --offline

Current result

POST /post HTTP/1.1
Accept: application/json, */*;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 21
Content-Type: application/json
Host: httpbin.org
User-Agent: HTTPie/3.0.0

{
    "foo": {
        "8": "bar"
    }
}

Expected result

Double a backslash anywhere should turn it into a literal backslash.

POST /post HTTP/1.1
Accept: application/json, */*;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 21
Content-Type: application/json
Host: httpbin.org
User-Agent: HTTPie/3.0.0

{
    "foo": {
        "\\8": "bar"
    }
}

Debug output

Please re-run the command with --debug, then copy the entire command & output and paste both below:

http httpbin.org/post 'foo[\\8]=bar' --offline --debug
HTTPie 3.0.0
Requests 2.22.0
Pygments 2.7.2
Python 3.8.5 (default, May 27 2021, 13:30:53)
[GCC 9.3.0]
/usr/bin/python3
Linux 5.10.81.1-microsoft-standard-WSL2

<Environment {'as_silent': <function Environment.as_silent at 0x7fc8d8712550>,
 'colors': 256,
 'config': {'default_options': []},
 'config_dir': PosixPath('/home/ducaale/.httpie'),
 'devnull': <property object at 0x7fc8d8aea950>,
 'is_windows': False,
 'log_error': <function Environment.log_error at 0x7fc8d87125e0>,
 'program_name': 'http',
 'stderr': <_io.TextIOWrapper name='<stderr>' mode='w' encoding='utf-8'>,
 'stderr_isatty': True,
 'stdin': <_io.TextIOWrapper name='<stdin>' mode='r' encoding='utf-8'>,
 'stdin_encoding': 'utf-8',
 'stdin_isatty': True,
 'stdout': <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>,
 'stdout_encoding': 'utf-8',
 'stdout_isatty': True}>

<PluginManager {'adapters': [],
 'auth': [<class 'httpie.plugins.builtin.BasicAuthPlugin'>,
          <class 'httpie.plugins.builtin.DigestAuthPlugin'>,
          <class 'httpie.plugins.builtin.BearerAuthPlugin'>],
 'converters': [],
 'formatters': [<class 'httpie.output.formatters.headers.HeadersFormatter'>,
                <class 'httpie.output.formatters.json.JSONFormatter'>,
                <class 'httpie.output.formatters.xml.XMLFormatter'>,
                <class 'httpie.output.formatters.colors.ColorFormatter'>]}>

>>> requests.request(**{'auth': None,
 'data': b'{"foo": {"8": "bar"}}',
 'headers': <HTTPHeadersDict('User-Agent': b'HTTPie/3.0.0', 'Accept': b'application/json, */*;q=0.5', 'Content-Type': b'application/json')>,
 'method': 'post',
 'params': <generator object MultiValueOrderedDict.items at 0x7fc8d83727b0>,
 'url': 'http://httpbin.org/post'})

POST /post HTTP/1.1
Accept: application/json, */*;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 21
Content-Type: application/json
Host: httpbin.org
User-Agent: HTTPie/3.0.0

{
    "foo": {
        "8": "bar"
    }
}

Additional information, screenshots, or code examples

N/A

@ducaale ducaale added bug Something isn't working new Needs triage. Comments are welcome! labels Jan 29, 2022
@isidentical isidentical removed the new Needs triage. Comments are welcome! label Jan 31, 2022
@isidentical isidentical self-assigned this Jan 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants