Skip to content

Commit 5f6d171

Browse files
AC-10541 - Web API Fix
1 parent dd4062f commit 5f6d171

File tree

2 files changed

+21
-20
lines changed

2 files changed

+21
-20
lines changed

app/code/Magento/Webapi/Controller/Rest/InputParamsResolver.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,32 @@ public function getInputData()
141141
} else {
142142
$inputData = $this->request->getRequestData();
143143
}
144+
$this->filterInputData($inputData);
144145
$this->validateParameters($serviceClassName, $serviceMethodName, array_keys($route->getParameters()));
145146

146147
return $this->paramsOverrider->override($inputData, $route->getParameters());
147148
}
148149

150+
/**
151+
* Validates InputData
152+
*
153+
* @param array $inputData
154+
* @return array
155+
*/
156+
private function filterInputData(array $inputData): array
157+
{
158+
$result = [];
159+
160+
$data = array_filter($inputData, function ($k) use (&$result) {
161+
$key = is_string($k) ? strtolower(str_replace('_', "", $k)) : $k;
162+
return !isset($result[$key]) && ($result[$key] = true);
163+
}, ARRAY_FILTER_USE_KEY);
164+
165+
return array_map(function ($value) {
166+
return is_array($value) ? $this->filterInputData($value) : $value;
167+
}, $data);
168+
}
169+
149170
/**
150171
* Retrieve current route.
151172
*

app/code/Magento/Webapi/Controller/Rest/ParamsOverrider.php

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -76,26 +76,6 @@ public function override(array $inputData, array $parameters)
7676
return $inputData;
7777
}
7878

79-
/**
80-
* Validates InputData
81-
*
82-
* @param array $inputData
83-
* @return array
84-
*/
85-
private function validateInputData(array $inputData): array
86-
{
87-
$result = [];
88-
89-
$data = array_filter($inputData, function ($k) use (&$result) {
90-
$key = is_string($k) ? strtolower(str_replace('_', "", $k)) : $k;
91-
return !isset($result[$key]) && ($result[$key] = true);
92-
}, ARRAY_FILTER_USE_KEY);
93-
94-
return array_map(function ($value) {
95-
return is_array($value) ? $this->validateInputData($value) : $value;
96-
}, $data);
97-
}
98-
9979
/**
10080
* Determine if a nested array value is set.
10181
*

0 commit comments

Comments
 (0)