Merge pull request #5847 from dhensby/pulls/3.2/fix-etag-quoting

FIX ETag header now properly quoted
This commit is contained in:
Damian Mooyman 2016-08-17 11:16:26 +12:00 committed by GitHub
commit 8028387c84
2 changed files with 12 additions and 0 deletions

View File

@ -302,6 +302,9 @@ class HTTP {
}
public static function register_etag($etag) {
if (0 !== strpos('"')) {
$etag = sprintf('"%s"', $etag);
}
self::$etag = $etag;
}
@ -447,6 +450,11 @@ class HTTP {
$responseHeaders['ETag'] = self::$etag;
}
// etag needs to be a quoted string according to HTTP spec
if (!empty($responseHeaders['ETag']) && 0 !== strpos($responseHeaders['ETag'], '"')) {
$responseHeaders['ETag'] = sprintf('"%s"', $responseHeaders['ETag']);
}
// Now that we've generated them, either output them or attach them to the SS_HTTPResponse as appropriate
foreach($responseHeaders as $k => $v) {
if($body) {

View File

@ -254,6 +254,10 @@ EOT
if(!headers_sent($file, $line)) {
header($_SERVER['SERVER_PROTOCOL'] . " $this->statusCode " . $this->getStatusDescription());
foreach($this->headers as $header => $value) {
//etags need to be quoted
if (strcasecmp('etag', $header) === 0 && 0 !== strpos($value, '"')) {
$value = sprintf('"%s"', $value);
}
header("$header: $value", true, $this->statusCode);
}
} else {