From 163fb1be4aa389f178a1ddf1c9fbd903e5ca21e8 Mon Sep 17 00:00:00 2001 From: Kevin Papst Date: Fri, 27 Mar 2020 00:55:23 +0100 Subject: [PATCH] fix non-ascii character break invoice download (#1592) --- src/Invoice/InvoiceFilename.php | 4 ++-- tests/Invoice/InvoiceFilenameTest.php | 12 ++++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/Invoice/InvoiceFilename.php b/src/Invoice/InvoiceFilename.php index b5612674..e20a7abf 100644 --- a/src/Invoice/InvoiceFilename.php +++ b/src/Invoice/InvoiceFilename.php @@ -30,8 +30,8 @@ final class InvoiceFilename } if (!empty($company)) { - $company = new UnicodeString($company); - $filename .= '-' . $company->snake(); + $uCompany = new UnicodeString($company); + $filename .= '-' . $uCompany->ascii()->snake(); } $this->filename = $filename; diff --git a/tests/Invoice/InvoiceFilenameTest.php b/tests/Invoice/InvoiceFilenameTest.php index d84f3b3d..f4eca948 100644 --- a/tests/Invoice/InvoiceFilenameTest.php +++ b/tests/Invoice/InvoiceFilenameTest.php @@ -47,7 +47,15 @@ class InvoiceFilenameTest extends TestCase $customer->setCompany('barß / laölala # ldksjf 123'); $sut = new InvoiceFilename($model); - self::assertEquals($datePrefix . '-barß_laölala_ldksjf123', $sut->getFilename()); - self::assertEquals($datePrefix . '-barß_laölala_ldksjf123', (string) $sut); + self::assertEquals($datePrefix . '-barss_laolala_ldksjf123', $sut->getFilename()); + self::assertEquals($datePrefix . '-barss_laolala_ldksjf123', (string) $sut); + + $customer->setCompany('까깨꺄꺠꺼께껴꼐꼬꽈sssss'); + $sut = new InvoiceFilename($model); + self::assertEquals($datePrefix . '-kkakkaekkyakkyaekkeokkekkyeokkyekkokkwasssss', $sut->getFilename()); + + $customer->setCompany('\"#+ß.!$%&/()=?\\n=/*-+´_<>@' . "\n"); + $sut = new InvoiceFilename($model); + self::assertEquals($datePrefix . '-ss_n', $sut->getFilename()); } }