Skip to content

Validate nullable locales #1919

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/PhpWord/Reader/Word2007/AbstractPart.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/PhpWord/Style/Language.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,10 @@ public function getBidirectional()
*/
private function validateLocale($locale)
{
if ($locale !== null) {
$locale = str_replace('_', '-', $locale);
}

if (strlen($locale) === 2) {
return strtolower($locale) . '-' . strtoupper($locale);
}
Expand Down