mirror of
https://github.com/linuxserver/Heimdall.git
synced 2025-12-06 06:53:55 +09:00
Update to laravel 7
This commit is contained in:
@@ -15,8 +15,6 @@ use Symfony\Component\Mime\Encoder\Rfc2231Encoder;
|
||||
|
||||
/**
|
||||
* @author Chris Corbyn
|
||||
*
|
||||
* @experimental in 4.3
|
||||
*/
|
||||
final class ParameterizedHeader extends UnstructuredHeader
|
||||
{
|
||||
@@ -25,7 +23,7 @@ final class ParameterizedHeader extends UnstructuredHeader
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const TOKEN_REGEX = '(?:[\x21\x23-\x27\x2A\x2B\x2D\x2E\x30-\x39\x41-\x5A\x5E-\x7E]+)';
|
||||
public const TOKEN_REGEX = '(?:[\x21\x23-\x27\x2A\x2B\x2D\x2E\x30-\x39\x41-\x5A\x5E-\x7E]+)';
|
||||
|
||||
private $encoder;
|
||||
private $parameters = [];
|
||||
@@ -38,7 +36,7 @@ final class ParameterizedHeader extends UnstructuredHeader
|
||||
$this->setParameter($k, $v);
|
||||
}
|
||||
|
||||
if ('content-disposition' === strtolower($name)) {
|
||||
if ('content-type' !== strtolower($name)) {
|
||||
$this->encoder = new Rfc2231Encoder();
|
||||
}
|
||||
}
|
||||
@@ -104,7 +102,7 @@ final class ParameterizedHeader extends UnstructuredHeader
|
||||
}
|
||||
|
||||
/**
|
||||
* Render a RFC 2047 compliant header parameter from the $name and $value.
|
||||
* Render an RFC 2047 compliant header parameter from the $name and $value.
|
||||
*/
|
||||
private function createParameter(string $name, string $value): string
|
||||
{
|
||||
@@ -125,6 +123,22 @@ final class ParameterizedHeader extends UnstructuredHeader
|
||||
$maxValueLength = $this->getMaxLineLength() - \strlen($name.'*N*="";') - 1;
|
||||
$firstLineOffset = \strlen($this->getCharset()."'".$this->getLanguage()."'");
|
||||
}
|
||||
|
||||
if (\in_array($name, ['name', 'filename'], true) && 'form-data' === $this->getValue() && 'content-disposition' === strtolower($this->getName()) && preg_match('//u', $value)) {
|
||||
// WHATWG HTML living standard 4.10.21.8 2 specifies:
|
||||
// For field names and filenames for file fields, the result of the
|
||||
// encoding in the previous bullet point must be escaped by replacing
|
||||
// any 0x0A (LF) bytes with the byte sequence `%0A`, 0x0D (CR) with `%0D`
|
||||
// and 0x22 (") with `%22`.
|
||||
// The user agent must not perform any other escapes.
|
||||
$value = str_replace(['"', "\r", "\n"], ['%22', '%0D', '%0A'], $value);
|
||||
|
||||
if (\strlen($value) <= $maxValueLength) {
|
||||
return $name.'="'.$value.'"';
|
||||
}
|
||||
|
||||
$value = $origValue;
|
||||
}
|
||||
}
|
||||
|
||||
// Encode if we need to
|
||||
@@ -160,7 +174,8 @@ final class ParameterizedHeader extends UnstructuredHeader
|
||||
*/
|
||||
private function getEndOfParameterValue(string $value, bool $encoded = false, bool $firstLine = false): string
|
||||
{
|
||||
if (!preg_match('/^'.self::TOKEN_REGEX.'$/D', $value)) {
|
||||
$forceHttpQuoting = 'form-data' === $this->getValue() && 'content-disposition' === strtolower($this->getName());
|
||||
if ($forceHttpQuoting || !preg_match('/^'.self::TOKEN_REGEX.'$/D', $value)) {
|
||||
$value = '"'.$value.'"';
|
||||
}
|
||||
$prepend = '=';
|
||||
|
||||
Reference in New Issue
Block a user