v2.1.3
This commit is contained in:
parent
3daee2df53
commit
19ef0566df
610 changed files with 21958 additions and 3112 deletions
33
vendor/aws/aws-sdk-php/src/CloudFront/Signer.php
vendored
33
vendor/aws/aws-sdk-php/src/CloudFront/Signer.php
vendored
|
|
@ -81,8 +81,10 @@ class Signer
|
|||
$signatureHash = [];
|
||||
if ($policy) {
|
||||
$policy = preg_replace('/\s/s', '', $policy);
|
||||
self::validatePolicy($policy);
|
||||
$signatureHash['Policy'] = $this->encode($policy);
|
||||
} elseif ($resource && $expires) {
|
||||
self::validateResourceUrl($resource);
|
||||
$expires = (int) $expires; // Handle epoch passed as string
|
||||
$policy = $this->createCannedPolicy($resource, $expires);
|
||||
$signatureHash['Expires'] = $expires;
|
||||
|
|
@ -136,4 +138,35 @@ class Signer
|
|||
{
|
||||
return strtr(base64_encode($policy), '+=/', '-_~');
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates a customer provided json document.
|
||||
*
|
||||
* @param string $jsonPolicy
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private static function validatePolicy(string $jsonPolicy): void
|
||||
{
|
||||
$policy = json_decode($jsonPolicy, true);
|
||||
foreach ($policy['Statement'] ?? [] as $statement) {
|
||||
if (isset($statement['Resource'])) {
|
||||
self::validateResourceUrl($statement['Resource']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $url
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private static function validateResourceUrl(string $url): void
|
||||
{
|
||||
if (preg_match('/["\\\\\x00-\x1F]/', $url)) {
|
||||
throw new \InvalidArgumentException(
|
||||
'URL contains invalid characters: ", \\, or control characters'
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue