mirror of
https://github.com/linuxserver/Heimdall.git
synced 2026-08-07 07:16:13 +00:00
f69cbba6cd
Bumps the packages reported by CVE/GHSA scans in #1564 to their patched releases (with transitive dependencies): - symfony/http-foundation 7.3.1 -> 7.4.14 (CVE-2025-64500 / GHSA-3rg7-wf37-54rm) - phpunit/phpunit 10.5.47 -> 10.5.64 (CVE-2026-24765 / GHSA-vvj3-c3rp-c85p) - aws/aws-sdk-php 3.349.3 -> 3.388.0 (GHSA-27qh-8cxx-2cr5) - enshrined/svg-sanitize 0.21.0 -> 0.22.0 (GHSA-22wq-q86m-83fh) Some transitive dependencies now require PHP 8.4, which matches the runtime shipped in the official LinuxServer image, so the composer requirement is raised to ^8.4, CI is pinned to PHP 8.4, and the readme is updated to match. The remaining advisories in the report (php84, curl, libpq, git, sqlite, busybox, coreutils) come from the LinuxServer base image, not this repository, and are addressed by rebuilding the image on an updated base. Refs #1564
184 lines
5.2 KiB
PHP
184 lines
5.2 KiB
PHP
<?php
|
|
namespace Aws\Api\Parser;
|
|
|
|
use Aws\Api\DateTimeResult;
|
|
use Aws\Api\ListShape;
|
|
use Aws\Api\MapShape;
|
|
use Aws\Api\Parser\Exception\ParserException;
|
|
use Aws\Api\Shape;
|
|
use Aws\Api\StructureShape;
|
|
|
|
/**
|
|
* @internal Implements standard XML parsing for REST-XML and Query protocols.
|
|
*/
|
|
class XmlParser
|
|
{
|
|
public function parse(StructureShape $shape, \SimpleXMLElement $value)
|
|
{
|
|
return $this->dispatch($shape, $value);
|
|
}
|
|
|
|
private function dispatch($shape, \SimpleXMLElement $value)
|
|
{
|
|
static $methods = [
|
|
'structure' => 'parse_structure',
|
|
'list' => 'parse_list',
|
|
'map' => 'parse_map',
|
|
'blob' => 'parse_blob',
|
|
'boolean' => 'parse_boolean',
|
|
'integer' => 'parse_integer',
|
|
'float' => 'parse_float',
|
|
'double' => 'parse_float',
|
|
'timestamp' => 'parse_timestamp',
|
|
];
|
|
|
|
$type = $shape['type'];
|
|
if (isset($methods[$type])) {
|
|
return $this->{$methods[$type]}($shape, $value);
|
|
}
|
|
|
|
return (string) $value;
|
|
}
|
|
|
|
private function parse_structure(
|
|
StructureShape $shape,
|
|
\SimpleXMLElement $value
|
|
) {
|
|
$target = [];
|
|
|
|
foreach ($shape->getMembers() as $name => $member) {
|
|
// Extract the name of the XML node
|
|
$node = $this->memberKey($member, $name);
|
|
if (isset($value->{$node})) {
|
|
$target[$name] = $this->dispatch($member, $value->{$node});
|
|
} else {
|
|
$memberShape = $shape->getMember($name);
|
|
if (!empty($memberShape['xmlAttribute'])) {
|
|
$target[$name] = $this->parse_xml_attribute(
|
|
$shape,
|
|
$memberShape,
|
|
$value
|
|
);
|
|
}
|
|
}
|
|
}
|
|
if (isset($shape['union'])
|
|
&& $shape['union']
|
|
&& empty($target)
|
|
) {
|
|
foreach ($value as $key => $val) {
|
|
$name = $val->children()->getName();
|
|
$target['Unknown'][$name] = $val->$name;
|
|
}
|
|
}
|
|
return $target;
|
|
}
|
|
|
|
private function memberKey(Shape $shape, $name)
|
|
{
|
|
// Check if locationName came from shape definition
|
|
if ($shape instanceof StructureShape && isset($shape['locationName'])) {
|
|
$originalDef = $shape->getOriginalDefinition($shape->getName());
|
|
|
|
if ($originalDef && isset($originalDef['locationName'])
|
|
&& $originalDef['locationName'] === $shape['locationName']
|
|
) {
|
|
return $name;
|
|
}
|
|
}
|
|
|
|
return $shape['locationName'] ?? $name;
|
|
}
|
|
|
|
private function parse_list(ListShape $shape, \SimpleXMLElement $value)
|
|
{
|
|
$target = [];
|
|
$member = $shape->getMember();
|
|
|
|
if (!$shape['flattened']) {
|
|
$value = $value->{$member['locationName'] ?: 'member'};
|
|
}
|
|
|
|
foreach ($value as $v) {
|
|
$target[] = $this->dispatch($member, $v);
|
|
}
|
|
|
|
return $target;
|
|
}
|
|
|
|
private function parse_map(MapShape $shape, \SimpleXMLElement $value)
|
|
{
|
|
$target = [];
|
|
|
|
if (!$shape['flattened']) {
|
|
$value = $value->entry;
|
|
}
|
|
|
|
$mapKey = $shape->getKey();
|
|
$mapValue = $shape->getValue();
|
|
$keyName = $shape->getKey()['locationName'] ?: 'key';
|
|
$valueName = $shape->getValue()['locationName'] ?: 'value';
|
|
|
|
foreach ($value as $node) {
|
|
$key = $this->dispatch($mapKey, $node->{$keyName});
|
|
$value = $this->dispatch($mapValue, $node->{$valueName});
|
|
$target[$key] = $value;
|
|
}
|
|
|
|
return $target;
|
|
}
|
|
|
|
private function parse_blob(Shape $shape, $value)
|
|
{
|
|
return base64_decode((string) $value);
|
|
}
|
|
|
|
private function parse_float(Shape $shape, $value)
|
|
{
|
|
$value = (string) $value;
|
|
|
|
return match ($value) {
|
|
'NaN', 'Infinity', '-Infinity' => $value,
|
|
default => (float) $value
|
|
};
|
|
}
|
|
|
|
private function parse_integer(Shape $shape, $value)
|
|
{
|
|
return (int) (string) $value;
|
|
}
|
|
|
|
private function parse_boolean(Shape $shape, $value)
|
|
{
|
|
return $value == 'true';
|
|
}
|
|
|
|
private function parse_timestamp(Shape $shape, $value)
|
|
{
|
|
if (is_string($value)
|
|
|| is_int($value)
|
|
|| (is_object($value)
|
|
&& method_exists($value, '__toString'))
|
|
) {
|
|
return DateTimeResult::fromTimestamp(
|
|
(string) $value,
|
|
!empty($shape['timestampFormat']) ? $shape['timestampFormat'] : null
|
|
);
|
|
}
|
|
throw new ParserException('Invalid timestamp value passed to XmlParser::parse_timestamp');
|
|
}
|
|
|
|
private function parse_xml_attribute(Shape $shape, Shape $memberShape, $value)
|
|
{
|
|
$namespace = $shape['xmlNamespace']['uri'] ?? '';
|
|
$prefix = $shape['xmlNamespace']['prefix'] ?? '';
|
|
if (!empty($prefix)) {
|
|
$prefix .= ':';
|
|
}
|
|
$key = str_replace($prefix, '', $memberShape['locationName']);
|
|
|
|
$attributes = $value->attributes($namespace);
|
|
return isset($attributes[$key]) ? (string) $attributes[$key] : null;
|
|
}
|
|
}
|