Skip to content

Commit 717107b

Browse files
committed
AC-10815 - API Input validation
1 parent 6b21de8 commit 717107b

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
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;
2526
use Magento\Framework\Webapi\Exception as WebapiException;
2627
use Magento\Framework\Webapi\CustomAttribute\PreprocessorInterface;
2728
use Laminas\Code\Reflection\ClassReflection;
@@ -247,8 +248,11 @@ private function getConstructorData(string $className, array $data): array
247248
$parameterType = $this->typeProcessor->getParamType($parameter);
248249

249250
try {
250-
if (strtolower($parameter->getName()) === "sourcedata" && $parameterType === "\Magento\Framework\Simplexml\Element") {
251-
throw new InputException(new Phrase('Request method is invalid.'));
251+
if (
252+
ltrim($parameterType, "\\") === SimplexmlElement::Class &&
253+
strtolower($parameter->getName()) === "sourcedata"
254+
) {
255+
throw new InputException(new Phrase('Invalid input.'));
252256
}
253257

254258
$res[$parameter->getName()] = $this->convertValue($data[$parameter->getName()], $parameterType);

0 commit comments

Comments
 (0)