diff --git a/lib/SP/Domain/Export/Services/XmlCategoryExport.php b/lib/SP/Domain/Export/Services/XmlCategoryExport.php index 5e4ff79e..441376cf 100644 --- a/lib/SP/Domain/Export/Services/XmlCategoryExport.php +++ b/lib/SP/Domain/Export/Services/XmlCategoryExport.php @@ -77,18 +77,18 @@ final class XmlCategoryExport extends Service implements XmlCategoryExportServic foreach ($categories as $category) { $nodeCategory = $document->createElement('Category'); + $nodeCategories->appendChild($nodeCategory); + $nodeCategory->setAttribute('id', $category->getId()); $nodeCategory->appendChild( - $document->createElement('name', XmlUtil::escapeChars($category->getName())) + $document->createElement('name', $document->createTextNode($category->getName())->nodeValue) ); $nodeCategory->appendChild( $document->createElement( 'description', - XmlUtil::escapeChars($category->getDescription()) + $document->createTextNode($category->getDescription())->nodeValue ) ); - - $nodeCategories->appendChild($nodeCategory); } return $nodeCategories; diff --git a/lib/SP/Domain/Export/Services/XmlClientExport.php b/lib/SP/Domain/Export/Services/XmlClientExport.php index 207c537e..c3c1027e 100644 --- a/lib/SP/Domain/Export/Services/XmlClientExport.php +++ b/lib/SP/Domain/Export/Services/XmlClientExport.php @@ -78,13 +78,18 @@ final class XmlClientExport extends Service implements XmlClientExportService foreach ($clients as $client) { $nodeClient = $document->createElement('Client'); - $nodeClient->setAttribute('id', $client->getId()); - $nodeClient->appendChild($document->createElement('name', XmlUtil::escapeChars($client->getName()))); - $nodeClient->appendChild( - $document->createElement('description', XmlUtil::escapeChars($client->getDescription())) - ); - $nodeClients->appendChild($nodeClient); + + $nodeClient->setAttribute('id', $client->getId()); + $nodeClient->appendChild( + $document->createElement('name', $document->createTextNode($client->getName())->nodeValue) + ); + $nodeClient->appendChild( + $document->createElement( + 'description', + $document->createTextNode($client->getDescription())->nodeValue + ) + ); } return $nodeClients; diff --git a/lib/SP/Domain/Export/Services/XmlTagExport.php b/lib/SP/Domain/Export/Services/XmlTagExport.php index 35e36a7c..0973a7e4 100644 --- a/lib/SP/Domain/Export/Services/XmlTagExport.php +++ b/lib/SP/Domain/Export/Services/XmlTagExport.php @@ -32,7 +32,6 @@ use SP\Core\Events\Event; use SP\Core\Events\EventMessage; use SP\Domain\Common\Services\Service; use SP\Domain\Common\Services\ServiceException; -use SP\Domain\Export\Services\XmlUtil; use SP\Domain\Tag\Services\TagService; use function SP\__u; @@ -43,7 +42,7 @@ use function SP\__u; final class XmlTagExport extends Service implements XmlTagExportService { public function __construct( - Application $application, + Application $application, private readonly TagService $tagService, ) { @@ -77,10 +76,12 @@ final class XmlTagExport extends Service implements XmlTagExportService foreach ($tags as $tag) { $nodeTag = $document->createElement('Tag'); - $nodeTag->setAttribute('id', $tag->getId()); - $nodeTag->appendChild($document->createElement('name', XmlUtil::escapeChars($tag->getName()))); - $nodeTags->appendChild($nodeTag); + + $nodeTag->setAttribute('id', $tag->getId()); + $nodeTag->appendChild( + $document->createElement('name', $document->createTextNode($tag->getName())->nodeValue) + ); } return $nodeTags; diff --git a/lib/SP/Domain/Export/Services/XmlUtil.php b/lib/SP/Domain/Export/Services/XmlUtil.php deleted file mode 100644 index 98e758ff..00000000 --- a/lib/SP/Domain/Export/Services/XmlUtil.php +++ /dev/null @@ -1,46 +0,0 @@ -. - */ - -namespace SP\Domain\Export\Services; - -/** - * Class XmlUtil - */ -final class XmlUtil -{ - /** - * Escapar carácteres no válidos en XML - * - * @param $data string Los datos a escapar - * - * @return string - */ - public static function escapeChars(string $data): string - { - $arrStrFrom = ['&', '<', '>', '"', '\'']; - $arrStrTo = ['&', '<', '>', '"', ''']; - - return str_replace($arrStrFrom, $arrStrTo, $data); - } -}