From 1a8a4b74238bf97207188338e171ac6b42f93e0f Mon Sep 17 00:00:00 2001 From: Robert Zondervan Date: Mon, 28 Jul 2025 12:47:53 +0200 Subject: [PATCH 1/2] Add XML Parsehuge to endpointservice --- src/Service/EndpointService.php | 104 ++++++++++++++++---------------- 1 file changed, 52 insertions(+), 52 deletions(-) diff --git a/src/Service/EndpointService.php b/src/Service/EndpointService.php index 22ee79bd..45fd4751 100644 --- a/src/Service/EndpointService.php +++ b/src/Service/EndpointService.php @@ -220,39 +220,39 @@ private function determineAcceptType(string $acceptHeader): ?string // Determine the accept type. $this->logger->debug('Determine accept type from accept header'); switch ($acceptHeader) { - case 'application/pdf': - return 'pdf'; - case 'application/json': - return 'json'; - case 'application/json+hal': - case 'application/hal+json': - return 'jsonhal'; - case 'application/json+ld': - case 'application/ld+json': - return 'jsonld'; - case 'application/json+fromio': - case 'application/formio+json': - return 'formio'; - case 'application/json+schema': - case 'application/schema+json': - return 'schema'; - case 'application/json+graphql': - case 'application/graphql+json': - return 'graphql'; - case 'text/xml': - case 'application/xml': - return 'xml'; - case 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': - return 'xlsx'; - case 'text/csv': - return 'csv'; - case 'text/html': - return 'html'; - case 'application/vnd.openxmlformats-officedocument.wordprocessingml.document': - return 'docx'; + case 'application/pdf': + return 'pdf'; + case 'application/json': + return 'json'; + case 'application/json+hal': + case 'application/hal+json': + return 'jsonhal'; + case 'application/json+ld': + case 'application/ld+json': + return 'jsonld'; + case 'application/json+fromio': + case 'application/formio+json': + return 'formio'; + case 'application/json+schema': + case 'application/schema+json': + return 'schema'; + case 'application/json+graphql': + case 'application/graphql+json': + return 'graphql'; + case 'text/xml': + case 'application/xml': + return 'xml'; + case 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': + return 'xlsx'; + case 'text/csv': + return 'csv'; + case 'text/html': + return 'html'; + case 'application/vnd.openxmlformats-officedocument.wordprocessingml.document': + return 'docx'; break; - case 'application/json+aggregations': - return 'aggregations'; + case 'application/json+aggregations': + return 'aggregations'; }//end switch return null; @@ -302,8 +302,8 @@ public function getAcceptType(): string if (count($pathparts) >= 2) { $extension = end($pathparts); switch ($extension) { - case 'pdf': - return 'pdf'; + case 'pdf': + return 'pdf'; }//end switch } @@ -334,14 +334,14 @@ public function decodeBody(): ?array // Decode the body. switch ($contentType) { - case 'text/xml': - case 'application/xml': - case 'xml': - $xmlEncoder = new XmlEncoder(); - - return $xmlEncoder->decode($this->request->getContent(), 'xml'); - default: - return json_decode($this->request->getContent(), true); + case 'text/xml': + case 'application/xml': + case 'xml': + $xmlEncoder = new XmlEncoder(['load_options' => LIBXML_PARSEHUGE]); + + return $xmlEncoder->decode($this->request->getContent(), 'xml'); + default: + return json_decode($this->request->getContent(), true); }//end switch }//end decodeBody() @@ -426,10 +426,10 @@ private function getPutData(): array $filename = null; if (preg_match( - '/^(.+); *name="([^"]+)"(; *filename="([^"]+)")?/', - $headers['content-disposition'], - $matches - ) === false + '/^(.+); *name="([^"]+)"(; *filename="([^"]+)")?/', + $headers['content-disposition'], + $matches + ) === false ) { preg_match( '/^(.+); *name=([-+.\w]+)(; *filename=([-+.\w]+))?/', @@ -444,14 +444,14 @@ private function getPutData(): array // Handle your fields here. switch ($name) { // This is a file upload. - case 'userfile': - file_put_contents($filename, $body); - break; + case 'userfile': + file_put_contents($filename, $body); + break; // Default for all other files is to populate $data. - default: - $data[$name] = substr($body, 0, (strlen($body) - 2)); - break; + default: + $data[$name] = substr($body, 0, (strlen($body) - 2)); + break; } }//end foreach From ce10656f644094792972c8b9900f183d1411a21a Mon Sep 17 00:00:00 2001 From: GitHub Actions <> Date: Mon, 28 Jul 2025 10:48:32 +0000 Subject: [PATCH 2/2] Update src from PHP Codesniffer --- src/Service/EndpointService.php | 104 ++++++++++++++++---------------- 1 file changed, 52 insertions(+), 52 deletions(-) diff --git a/src/Service/EndpointService.php b/src/Service/EndpointService.php index 45fd4751..a2906beb 100644 --- a/src/Service/EndpointService.php +++ b/src/Service/EndpointService.php @@ -220,39 +220,39 @@ private function determineAcceptType(string $acceptHeader): ?string // Determine the accept type. $this->logger->debug('Determine accept type from accept header'); switch ($acceptHeader) { - case 'application/pdf': - return 'pdf'; - case 'application/json': - return 'json'; - case 'application/json+hal': - case 'application/hal+json': - return 'jsonhal'; - case 'application/json+ld': - case 'application/ld+json': - return 'jsonld'; - case 'application/json+fromio': - case 'application/formio+json': - return 'formio'; - case 'application/json+schema': - case 'application/schema+json': - return 'schema'; - case 'application/json+graphql': - case 'application/graphql+json': - return 'graphql'; - case 'text/xml': - case 'application/xml': - return 'xml'; - case 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': - return 'xlsx'; - case 'text/csv': - return 'csv'; - case 'text/html': - return 'html'; - case 'application/vnd.openxmlformats-officedocument.wordprocessingml.document': - return 'docx'; + case 'application/pdf': + return 'pdf'; + case 'application/json': + return 'json'; + case 'application/json+hal': + case 'application/hal+json': + return 'jsonhal'; + case 'application/json+ld': + case 'application/ld+json': + return 'jsonld'; + case 'application/json+fromio': + case 'application/formio+json': + return 'formio'; + case 'application/json+schema': + case 'application/schema+json': + return 'schema'; + case 'application/json+graphql': + case 'application/graphql+json': + return 'graphql'; + case 'text/xml': + case 'application/xml': + return 'xml'; + case 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': + return 'xlsx'; + case 'text/csv': + return 'csv'; + case 'text/html': + return 'html'; + case 'application/vnd.openxmlformats-officedocument.wordprocessingml.document': + return 'docx'; break; - case 'application/json+aggregations': - return 'aggregations'; + case 'application/json+aggregations': + return 'aggregations'; }//end switch return null; @@ -302,8 +302,8 @@ public function getAcceptType(): string if (count($pathparts) >= 2) { $extension = end($pathparts); switch ($extension) { - case 'pdf': - return 'pdf'; + case 'pdf': + return 'pdf'; }//end switch } @@ -334,14 +334,14 @@ public function decodeBody(): ?array // Decode the body. switch ($contentType) { - case 'text/xml': - case 'application/xml': - case 'xml': - $xmlEncoder = new XmlEncoder(['load_options' => LIBXML_PARSEHUGE]); - - return $xmlEncoder->decode($this->request->getContent(), 'xml'); - default: - return json_decode($this->request->getContent(), true); + case 'text/xml': + case 'application/xml': + case 'xml': + $xmlEncoder = new XmlEncoder(['load_options' => LIBXML_PARSEHUGE]); + + return $xmlEncoder->decode($this->request->getContent(), 'xml'); + default: + return json_decode($this->request->getContent(), true); }//end switch }//end decodeBody() @@ -426,10 +426,10 @@ private function getPutData(): array $filename = null; if (preg_match( - '/^(.+); *name="([^"]+)"(; *filename="([^"]+)")?/', - $headers['content-disposition'], - $matches - ) === false + '/^(.+); *name="([^"]+)"(; *filename="([^"]+)")?/', + $headers['content-disposition'], + $matches + ) === false ) { preg_match( '/^(.+); *name=([-+.\w]+)(; *filename=([-+.\w]+))?/', @@ -444,14 +444,14 @@ private function getPutData(): array // Handle your fields here. switch ($name) { // This is a file upload. - case 'userfile': - file_put_contents($filename, $body); - break; + case 'userfile': + file_put_contents($filename, $body); + break; // Default for all other files is to populate $data. - default: - $data[$name] = substr($body, 0, (strlen($body) - 2)); - break; + default: + $data[$name] = substr($body, 0, (strlen($body) - 2)); + break; } }//end foreach