Skip to content

Commit ccaf0f6

Browse files
authored
Webservice: Allow receiving body content in JSON format - BT#22611
1 parent 32c4dea commit ccaf0f6

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

main/webservices/api/v2.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,20 @@
2323

2424
$httpRequest = HttpRequest::createFromGlobals();
2525

26+
$jsonContent = 'application/json' === $httpRequest->headers->get('Content-Type')
27+
? json_decode($httpRequest->getContent(), true)
28+
: null;
29+
30+
if ($jsonContent) {
31+
foreach ($jsonContent as $key => $value) {
32+
$value = Security::remove_XSS($value);
33+
34+
$httpRequest->query->set($key, $value);
35+
$httpRequest->request->set($key, $value);
36+
$httpRequest->overrideGlobals();
37+
}
38+
}
39+
2640
$hash = $httpRequest->query->get('hash');
2741

2842
if ($hash) {

0 commit comments

Comments
 (0)