From db41207589d31a0d481732e7da43de05acbb82d0 Mon Sep 17 00:00:00 2001 From: Frederic Steinfels Date: Sun, 11 Oct 2026 23:36:03 +0200 Subject: [PATCH] Fix TypeError on null TransactionKey in Transfer segments; raise Base64 limits In EBICS downloads with multiple segments the Transfer-phase response does not carry a element - the key is only sent in the Initialization response and reused on the client side. v3.0.1 tolerated the null via native base64_decode(); v3.2.0 switched to Base64Encoder with strict 'string $data' type-hint, causing a TypeError on every multi-segment download. The second fix raises MAX_ENCODED_LENGTH / MAX_RAW_LENGTH to 512 MB / 384 MB respectively, so aggregated DAR responses (dozens of PDFs in one response) do not hit the ceiling until a true buffered variant exists. --- src/Handlers/ResponseHandler.php | 4 ++-- src/Services/Processor/Base64Encoder.php | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Handlers/ResponseHandler.php b/src/Handlers/ResponseHandler.php index 12d8987..083786b 100644 --- a/src/Handlers/ResponseHandler.php +++ b/src/Handlers/ResponseHandler.php @@ -130,7 +130,7 @@ public function retrieveH000ReportText(DOMDocument $xml): string public function extractInitializationSegment(Response $response, Keyring $keyring): InitializationSegment { $transactionKeyEncoded = $this->retrieveH00XTransactionKey($response); - $transactionKey = $this->base64Service->decode($transactionKeyEncoded); + $transactionKey = $transactionKeyEncoded !== null ? $this->base64Service->decode($transactionKeyEncoded) : ''; $orderDataEncrypted = $this->base64Service->decode($this->retrieveH00XOrderData($response)); $orderDataCompressed = $this->cryptService->decryptOrderDataCompressed( @@ -154,7 +154,7 @@ public function extractDownloadSegment(Response $response): DownloadSegment $transactionId = $this->retrieveH00XTransactionId($response); $transactionPhase = $this->retrieveH00XTransactionPhase($response); $transactionKeyEncoded = $this->retrieveH00XTransactionKey($response); - $transactionKey = $this->base64Service->decode($transactionKeyEncoded); + $transactionKey = $transactionKeyEncoded !== null ? $this->base64Service->decode($transactionKeyEncoded) : ''; $numSegments = $this->retrieveH00XNumSegments($response); $segmentNumber = $this->retrieveH00XSegmentNumber($response); $orderDataEncrypted = $this->retrieveH00XOrderData($response); diff --git a/src/Services/Processor/Base64Encoder.php b/src/Services/Processor/Base64Encoder.php index 24c5b0f..c8f0630 100644 --- a/src/Services/Processor/Base64Encoder.php +++ b/src/Services/Processor/Base64Encoder.php @@ -13,10 +13,10 @@ */ final class Base64Encoder implements Base64EncoderInterface { - /** Max encoded length = 10 * 1024 * 1024 (10 MB) */ - private const MAX_ENCODED_LENGTH = 10485760; - /** Max raw length = MAX_ENCODED_LENGTH * 3 / 4 (~7.5 MB) */ - private const MAX_RAW_LENGTH = 7864320; + /** Max encoded length = 512 * 1024 * 1024 (512 MB) */ + private const MAX_ENCODED_LENGTH = 536870912; + /** Max raw length = MAX_ENCODED_LENGTH * 3 / 4 (~384 MB) */ + private const MAX_RAW_LENGTH = 402653184; public function encode(string $data): string {