Skip to content
Permalink
Browse files

FIX ETag header now properly quoted

  • Loading branch information...
dhensby committed Jul 28, 2016
1 parent 6666845 commit 56f0b72e8dbf5b7205ae12c80e0f4c9a0614d1a2
Showing with 12 additions and 0 deletions.
  1. +8 −0 control/HTTP.php
  2. +4 −0 control/HTTPResponse.php
@@ -302,6 +302,9 @@ public static function register_modification_timestamp($timestamp) {
}
public static function register_etag($etag) {
if (0 !== strpos('"')) {

This comment has been minimized.

Copy link
@tractorcow

tractorcow Sep 6, 2016

Contributor

oops, strpos with one arg?

This comment has been minimized.

Copy link
@dhensby

dhensby Sep 6, 2016

Author Member

how the...

This comment has been minimized.

Copy link
@dhensby

dhensby Sep 6, 2016

Author Member

fix here #5959

$etag = sprintf('"%s"', $etag);
}
self::$etag = $etag;
}
@@ -447,6 +450,11 @@ public static function add_cache_headers($body = null) {
$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) {
@@ -254,6 +254,10 @@ public function output() {
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 {

0 comments on commit 56f0b72

Please sign in to comment.
You can’t perform that action at this time.