From 75e60d3a68ec20e9659f8b6991b9a1e3abcb5cb6 Mon Sep 17 00:00:00 2001 From: Ali Mohammad Pur Date: Sun, 31 Dec 2023 17:31:29 +0330 Subject: [PATCH] LibHTTP: Tolerate random whitespace in chunked encoding size field Some servers decide to add newlines (and not \r\n) into that field, this commit makes us tolerate that and not crash in cases like in #22463. Fixes #22463. --- Userland/Libraries/LibHTTP/Job.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Userland/Libraries/LibHTTP/Job.cpp b/Userland/Libraries/LibHTTP/Job.cpp index e4dcee57b0..56fe5b4410 100644 --- a/Userland/Libraries/LibHTTP/Job.cpp +++ b/Userland/Libraries/LibHTTP/Job.cpp @@ -413,7 +413,7 @@ void Job::on_socket_connected() m_should_read_chunk_ending_line = false; continue; } - auto size_lines = size_data.view().lines(); + auto size_lines = size_data.view().trim_whitespace().lines(); dbgln_if(JOB_DEBUG, "Job: Received a chunk with size '{}'", size_data); if (size_lines.size() == 0) { if (!m_socket->is_eof())