Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
*/
namespace Magento\Framework\Webapi\Rest\Response\Renderer;

/**
* Renders response data in Xml format.
*/
class Xml implements \Magento\Framework\Webapi\Rest\Response\RendererInterface
{
/**
Expand Down Expand Up @@ -111,8 +114,7 @@ protected function _formatValue($value)
/** Without the following transformation boolean values are rendered incorrectly */
$value = $value ? 'true' : 'false';
}
$replacementMap = ['&' => '&'];
return str_replace(array_keys($replacementMap), array_values($replacementMap), $value);
return (string) $value;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ public function providerXmlRender()
'<?xml version="1.0"?><response><item_7key>value</item_7key></response>',
'Invalid XML render with numeric symbol in data index.'
],
[
['key' => 'test & foo'],
'<?xml version="1.0"?><response><key>test &amp; foo</key></response>',
'Invalid XML render with ampersand symbol in data index.'
],
[
['.key' => 'value'],
'<?xml version="1.0"?><response><item_key>value</item_key></response>',
Expand Down