From a0e57459dcbe8645184f636f648739d84da6bcdf Mon Sep 17 00:00:00 2001 From: Ernestas Staugaitis Date: Sun, 16 Feb 2020 22:12:34 +0200 Subject: [PATCH 1/3] Some document have non-standard locale code --- src/PhpWord/Style/Language.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/PhpWord/Style/Language.php b/src/PhpWord/Style/Language.php index 18ef88975f..2ccc44c7c2 100644 --- a/src/PhpWord/Style/Language.php +++ b/src/PhpWord/Style/Language.php @@ -228,6 +228,8 @@ public function getBidirectional() */ private function validateLocale($locale) { + $locale = str_replace('_', '-', $locale); + if (strlen($locale) === 2) { return strtolower($locale) . '-' . strtoupper($locale); } From 37c15e66cda2820162e07ff12db2782c64382b28 Mon Sep 17 00:00:00 2001 From: Ernestas Staugaitis Date: Mon, 17 Feb 2020 11:44:27 +0200 Subject: [PATCH 2/3] Some document have non-standard locale code --- src/PhpWord/Style/Language.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/PhpWord/Style/Language.php b/src/PhpWord/Style/Language.php index 2ccc44c7c2..7b2de51e07 100644 --- a/src/PhpWord/Style/Language.php +++ b/src/PhpWord/Style/Language.php @@ -228,7 +228,9 @@ public function getBidirectional() */ private function validateLocale($locale) { - $locale = str_replace('_', '-', $locale); + if ($locale !== null) { + $locale = str_replace('_', '-', $locale); + } if (strlen($locale) === 2) { return strtolower($locale) . '-' . strtoupper($locale); From 453cd3439ca1423e471d7f26565cdbf817c74b4a Mon Sep 17 00:00:00 2001 From: Ernestas Staugaitis Date: Thu, 20 Aug 2020 17:25:11 +0300 Subject: [PATCH 3/3] Removed emf and wmf image reading as it is not supported on unix systems --- src/PhpWord/Reader/Word2007/AbstractPart.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/PhpWord/Reader/Word2007/AbstractPart.php b/src/PhpWord/Reader/Word2007/AbstractPart.php index 06dfe37bb8..74ca591951 100644 --- a/src/PhpWord/Reader/Word2007/AbstractPart.php +++ b/src/PhpWord/Reader/Word2007/AbstractPart.php @@ -259,7 +259,10 @@ protected function readRunChild(XMLReader $xmlReader, \DOMElement $node, Abstrac } else { $imageSource = "zip://{$this->docFile}#{$target}"; } - $parent->addImage($imageSource); + $extension = pathinfo($imageSource, PATHINFO_EXTENSION); + if($extension !== 'emf' && $extension !== 'wmf') { //windows OS specific images + $parent->addImage($imageSource); + } } } elseif ($node->nodeName == 'w:drawing') { // Office 2011 Image @@ -277,7 +280,11 @@ protected function readRunChild(XMLReader $xmlReader, \DOMElement $node, Abstrac $target = $this->getMediaTarget($docPart, $embedId); if (!is_null($target)) { $imageSource = "zip://{$this->docFile}#{$target}"; - $parent->addImage($imageSource, null, false, $name); + $extension = pathinfo($imageSource, PATHINFO_EXTENSION); + if($extension !== 'emf' && $extension !== 'wmf') { //windows OS specific images + $parent->addImage($imageSource, null, false, $name); + } + } } elseif ($node->nodeName == 'w:object') { // Object