Skip to content

Commit 2a0af7a

Browse files
committed
AC-10815 - API Input validation
1 parent 7b71402 commit 2a0af7a

File tree

4 files changed

+3
-14
lines changed

4 files changed

+3
-14
lines changed

app/design/adminhtml/Magento/backend/i18n/en_US.csv

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,4 +547,3 @@ Dashboard,Dashboard
547547
"Web Section","Web Section"
548548
"Store Email Addresses Section","Store Email Addresses Section"
549549
"Email to a Friend","Email to a Friend"
550-
"Invalid input.","Invalid input."

app/design/frontend/Magento/blank/i18n/en_US.csv

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,6 @@
423423
"You need write permissions for: %1","You need write permissions for: %1"
424424
"Your operating system is not supported to work with this command","Your operating system is not supported to work with this command"
425425
"Zookeeper connection timed out!","Zookeeper connection timed out!"
426-
"Invalid input.","Invalid input."
427426
Account,Account
428427
CSV,CSV
429428
dummy,dummy

app/design/frontend/Magento/luma/i18n/en_US.csv

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,6 @@
472472
"Your Shipment #%shipment_id for Order #%order_id","Your Shipment #%shipment_id for Order #%order_id"
473473
"Your shipping confirmation is below. Thank you again for your business.","Your shipping confirmation is below. Thank you again for your business."
474474
"Zookeeper connection timed out!","Zookeeper connection timed out!"
475-
"Invalid input.","Invalid input."
476475
CSV,CSV
477476
dummy,dummy
478477
Email:,Email:

lib/internal/Magento/Framework/Webapi/ServiceInputProcessor.php

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
use Magento\Framework\Phrase;
2323
use Magento\Framework\Reflection\MethodsMap;
2424
use Magento\Framework\Reflection\TypeProcessor;
25-
use Magento\Framework\Simplexml\Element as SimplexmlElement;
2625
use Magento\Framework\Webapi\Exception as WebapiException;
2726
use Magento\Framework\Webapi\CustomAttribute\PreprocessorInterface;
2827
use Laminas\Code\Reflection\ClassReflection;
@@ -38,11 +37,6 @@
3837
*/
3938
class ServiceInputProcessor implements ServicePayloadConverterInterface, ResetAfterRequestInterface
4039
{
41-
/**
42-
* Input param to be rejected when it contains xml content
43-
*/
44-
private const REJECTED_INPUT_PARAM_SOURCEDATA = 'sourcedata';
45-
4640
public const EXTENSION_ATTRIBUTES_TYPE = \Magento\Framework\Api\ExtensionAttributesInterface::class;
4741

4842
/**
@@ -235,6 +229,9 @@ private function getConstructorData(string $className, array $data): array
235229
{
236230
$preferenceClass = $this->config->getPreference($className);
237231
$class = new ClassReflection($preferenceClass ?: $className);
232+
if ($class->isSubclassOf(\SimpleXMLElement::class) || $class->isSubclassOf( \DOMNode::class)) {
233+
return [];
234+
}
238235

239236
try {
240237
$constructor = $class->getMethod('__construct');
@@ -253,11 +250,6 @@ private function getConstructorData(string $className, array $data): array
253250
$parameterType = $this->typeProcessor->getParamType($parameter);
254251

255252
try {
256-
if (ltrim($parameterType, "\\") === SimplexmlElement::Class &&
257-
strtolower($parameter->getName()) === self::REJECTED_INPUT_PARAM_SOURCEDATA) {
258-
throw new InputException(new Phrase('Invalid input.'));
259-
}
260-
261253
$res[$parameter->getName()] = $this->convertValue($data[$parameter->getName()], $parameterType);
262254
} catch (\ReflectionException $e) {
263255
// Parameter was not correclty declared or the class is uknown.

0 commit comments

Comments
 (0)