From c0bc067143bb0998ccf09fa04719d38ba77cb8df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Miguel=20Moreno?= Date: Sat, 7 Dec 2024 17:22:57 +0100 Subject: [PATCH] =?UTF-8?q?Normalizados=20saltos=20de=20l=C3=ADnea=20al=20?= =?UTF-8?q?firmar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Actualizada clase FacturaeSigner - Actualizados tests unitarios > Relacionado con #175 --- src/Common/FacturaeSigner.php | 4 ++++ tests/SignerTest.php | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/Common/FacturaeSigner.php b/src/Common/FacturaeSigner.php index ba512db..8615bbc 100644 --- a/src/Common/FacturaeSigner.php +++ b/src/Common/FacturaeSigner.php @@ -129,6 +129,10 @@ public function sign($xml) { throw new RuntimeException('Invalid signing key material: failed to read private key'); } + // Normalize line breaks + $xml = str_replace("\r\n", "\n", $xml); + $xml = str_replace("\r", "\n", $xml); + // Extract root element $openTagPosition = mb_strpos($xml, 'This contains\r\nWindows line breaks\n" . + " This contains\rclassic MacOS line breaks\n" . + ''; + $signedXml = $this->getSigner()->sign($xml); + $this->assertStringNotContainsString("\r", $signedXml); + } + + public function testCannotTimestampWithoutTsaDetails() { $this->expectException(RuntimeException::class); $signer = new FacturaeSigner();