From acc0cdb547b53f0931f55eb52f10c468a923ad9b Mon Sep 17 00:00:00 2001 From: Vinay Kumar Date: Tue, 3 Nov 2026 21:50:22 +0530 Subject: [PATCH 1/3] Fix #1965: A JSON body that starts with a brace can be parsed from the middle --- httpie/output/utils.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/httpie/output/utils.py b/httpie/output/utils.py index 875e885586..1ed8834e35 100644 --- a/httpie/output/utils.py +++ b/httpie/output/utils.py @@ -31,7 +31,14 @@ def parse_prefixed_json(data: str) -> Tuple[str, str]: Return a tuple (data prefix, actual JSON body). """ - matches = re.findall(PREFIX_REGEX, data) + # Find matches that start at the beginning of the string + matches = [] + for match in re.finditer(PREFIX_REGEX, data): + if match.start() == 0: + matches.append(match.group()) + else: + break + data_prefix = matches[0] if matches else '' body = data[len(data_prefix):] - return data_prefix, body + return data_prefix, body \ No newline at end of file From aeeb745d895fb8b1402e9ad83de45b5285f640d7 Mon Sep 17 00:00:00 2001 From: Vinay Kumar Date: Tue, 3 Nov 2026 21:51:29 +0530 Subject: [PATCH 2/3] Fix #1965: A JSON body that starts with a brace can be parsed from the middle From 9def35d211b821b6b006895e85466705377b3289 Mon Sep 17 00:00:00 2001 From: Vinay Kumar Date: Tue, 3 Nov 2026 21:52:36 +0530 Subject: [PATCH 3/3] Fix #1965: A JSON body that starts with a brace can be parsed from the middle --- httpie/output/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpie/output/utils.py b/httpie/output/utils.py index 1ed8834e35..b99b93896d 100644 --- a/httpie/output/utils.py +++ b/httpie/output/utils.py @@ -41,4 +41,4 @@ def parse_prefixed_json(data: str) -> Tuple[str, str]: data_prefix = matches[0] if matches else '' body = data[len(data_prefix):] - return data_prefix, body \ No newline at end of file + return data_prefix, body