diff options
author | Timur <timochka@gmail.com> | 2021-02-16 11:19:34 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-16 09:19:34 +0100 |
commit | e629920a09595eb45ffd6207de6c002a5501ce64 (patch) | |
tree | 5ceb0f484189eefec79e32ad08983774eb69e34a | |
parent | ac598fd9d6a7a5e16c06912afb88c974a317efdc (diff) |
Use standard shlex.quote (#189)
-rw-r--r-- | http_prompt/context/transform.py | 6 | ||||
-rw-r--r-- | http_prompt/utils.py | 6 |
2 files changed, 4 insertions, 8 deletions
diff --git a/http_prompt/context/transform.py b/http_prompt/context/transform.py index ea0cee4..ed13a7f 100644 --- a/http_prompt/context/transform.py +++ b/http_prompt/context/transform.py @@ -53,10 +53,8 @@ def _extract_httpie_request_items(context, quote=False): for k, value in sorted(item_dict.items()): if sep == ':=': json_str = json.dumps(value, - sort_keys=True).replace("'", "\\'") - if isinstance(value, str) and quote: - json_str = "'" + json_str + "'" - item = quote_func('%s:=%s' % (k, json_str)) + sort_keys=True) + item = '%s:=%s' % (k, quote_func(json_str)) items.append(item) elif isinstance(value, (list, tuple)): for v in value: diff --git a/http_prompt/utils.py b/http_prompt/utils.py index 1b71d90..f9536b1 100644 --- a/http_prompt/utils.py +++ b/http_prompt/utils.py @@ -2,6 +2,7 @@ from __future__ import unicode_literals import math import re +import shlex from prompt_toolkit.shortcuts import create_output @@ -10,10 +11,7 @@ RE_ANSI_ESCAPE = re.compile(r'\x1b[^m]*m') def smart_quote(s): - # TODO: Escape - if ' ' in s or r'\:' in s: - s = "'" + s + "'" - return s + return shlex.quote(s) def unquote(s): |