From 2fe0647c681d91f471d821700e2b5d05ec640a3b Mon Sep 17 00:00:00 2001 From: Lucas CHOLLET Date: Sat, 11 Nov 2023 17:38:53 -0500 Subject: [PATCH] LibPDF: Handle pdf-specific white spaces correctly in ASCII85 We were previously only looking the space character but PDF white spaces is a superset of ascii spaces. --- Userland/Libraries/LibPDF/Filter.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Userland/Libraries/LibPDF/Filter.cpp b/Userland/Libraries/LibPDF/Filter.cpp index 6285075e9b..93b725182f 100644 --- a/Userland/Libraries/LibPDF/Filter.cpp +++ b/Userland/Libraries/LibPDF/Filter.cpp @@ -11,6 +11,7 @@ #include #include #include +#include namespace PDF { @@ -99,7 +100,7 @@ PDFErrorOr Filter::decode_ascii85(ReadonlyBytes bytes) size_t byte_index = 0; while (byte_index < bytes.size()) { - if (bytes[byte_index] == ' ') { + if (Reader::is_whitespace(bytes[byte_index])) { byte_index++; continue; } @@ -117,7 +118,7 @@ PDFErrorOr Filter::decode_ascii85(ReadonlyBytes bytes) auto to_write = bytes.size() - byte_index; for (int i = 0; i < 5; i++) { auto byte = byte_index >= bytes.size() ? 'u' : bytes[byte_index++]; - if (byte == ' ') { + if (Reader::is_whitespace(byte)) { i--; continue; } @@ -131,7 +132,7 @@ PDFErrorOr Filter::decode_ascii85(ReadonlyBytes bytes) } else { for (int i = 0; i < 5; i++) { auto byte = bytes[byte_index++]; - if (byte == ' ') { + if (Reader::is_whitespace(byte)) { i--; continue; }