Fixed line lengths

This commit is contained in:
Ingo Schommer 2013-02-18 14:41:49 +01:00
parent 9e2e050f20
commit 92458d9f43
6 changed files with 43 additions and 17 deletions

View File

@ -288,7 +288,8 @@ class HTTP {
$responseHeaders["Cache-Control"] = "max-age=" . self::$cache_age . ", must-revalidate, no-transform"; $responseHeaders["Cache-Control"] = "max-age=" . self::$cache_age . ", must-revalidate, no-transform";
$responseHeaders["Pragma"] = ""; $responseHeaders["Pragma"] = "";
// To do: User-Agent should only be added in situations where you *are* actually varying according to user-agent. // To do: User-Agent should only be added in situations where you *are* actually
// varying according to user-agent.
$responseHeaders['Vary'] = 'Cookie, X-Forwarded-Protocol, User-Agent, Accept'; $responseHeaders['Vary'] = 'Cookie, X-Forwarded-Protocol, User-Agent, Accept';
} else { } else {
@ -298,13 +299,12 @@ class HTTP {
if(self::$modification_date && self::$cache_age > 0) { if(self::$modification_date && self::$cache_age > 0) {
$responseHeaders["Last-Modified"] = self::gmt_date(self::$modification_date); $responseHeaders["Last-Modified"] = self::gmt_date(self::$modification_date);
/* Chrome ignores Varies when redirecting back (http://code.google.com/p/chromium/issues/detail?id=79758) // Chrome ignores Varies when redirecting back (http://code.google.com/p/chromium/issues/detail?id=79758)
which means that if you log out, you get redirected back to a page which Chrome then checks against last-modified (which passes, getting a 304) // which means that if you log out, you get redirected back to a page which Chrome then checks against
when it shouldn't be trying to use that page at all because it's the "logged in" version. // last-modified (which passes, getting a 304)
// when it shouldn't be trying to use that page at all because it's the "logged in" version.
By also using and etag that includes both the modification date and all the varies values which we also check against we can catch // By also using and etag that includes both the modification date and all the varies
this and not return a 304 // values which we also check against we can catch this and not return a 304
*/
$etagParts = array(self::$modification_date, serialize($_COOKIE)); $etagParts = array(self::$modification_date, serialize($_COOKIE));
if (isset($_SERVER['HTTP_X_FORWARDED_PROTOCOL'])) $etagParts[] = $_SERVER['HTTP_X_FORWARDED_PROTOCOL']; if (isset($_SERVER['HTTP_X_FORWARDED_PROTOCOL'])) $etagParts[] = $_SERVER['HTTP_X_FORWARDED_PROTOCOL'];
if (isset($_SERVER['HTTP_USER_AGENT'])) $etagParts[] = $_SERVER['HTTP_USER_AGENT']; if (isset($_SERVER['HTTP_USER_AGENT'])) $etagParts[] = $_SERVER['HTTP_USER_AGENT'];

View File

@ -151,7 +151,8 @@ class SS_HTTPResponse {
public function setBody($body) { public function setBody($body) {
$this->body = $body; $this->body = $body;
// Set content-length in bytes. Use mbstring to avoid problems with mb_internal_encoding() and mbstring.func_overload // Set content-length in bytes. Use mbstring to avoid problems with
// mb_internal_encoding() and mbstring.func_overload
$this->headers['Content-Length'] = mb_strlen($this->body,'8bit'); $this->headers['Content-Length'] = mb_strlen($this->body,'8bit');
} }
@ -232,7 +233,11 @@ class SS_HTTPResponse {
} else { } else {
// It's critical that these status codes are sent; we need to report a failure if not. // It's critical that these status codes are sent; we need to report a failure if not.
if($this->statusCode >= 300) { if($this->statusCode >= 300) {
user_error("Couldn't set response type to $this->statusCode because of output on line $line of $file", E_USER_WARNING); user_error(
"Couldn't set response type to $this->statusCode because " .
"of output on line $line of $file",
E_USER_WARNING
);
} }
} }

View File

@ -248,7 +248,15 @@ class Debug {
ini_set('display_errors', 0); ini_set('display_errors', 0);
if(self::$send_warnings_to) { if(self::$send_warnings_to) {
return self::emailError(self::$send_warnings_to, $errno, $errstr, $errfile, $errline, $errcontext, "Warning"); return self::emailError(
self::$send_warnings_to,
$errno,
$errstr,
$errfile,
$errline,
$errcontext,
"Warning"
);
} }
// Send out the error details to the logger for writing // Send out the error details to the logger for writing

View File

@ -715,7 +715,9 @@ class Form extends RequestHandler {
$needsCacheDisabled = false; $needsCacheDisabled = false;
if ($this->getSecurityToken()->isEnabled()) $needsCacheDisabled = true; if ($this->getSecurityToken()->isEnabled()) $needsCacheDisabled = true;
if ($this->FormMethod() != 'get') $needsCacheDisabled = true; if ($this->FormMethod() != 'get') $needsCacheDisabled = true;
if (!($this->validator instanceof RequiredFields) || count($this->validator->getRequired())) $needsCacheDisabled = true; if (!($this->validator instanceof RequiredFields) || count($this->validator->getRequired())) {
$needsCacheDisabled = true;
}
// If we need to disable cache, do it // If we need to disable cache, do it
if ($needsCacheDisabled) HTTP::set_cache_age(0); if ($needsCacheDisabled) HTTP::set_cache_age(0);

View File

@ -144,11 +144,21 @@ class HTMLText extends Text {
*/ */
public function exists() { public function exists() {
// If it's blank, it's blank // If it's blank, it's blank
if(!parent::exists()) return false; if(!parent::exists()) {
return false;
}
// If it's got a content tag // If it's got a content tag
if(preg_match('/<(img|embed|object|iframe)[^>]*>/i', $this->value)) return true; if(preg_match('/<(img|embed|object|iframe)[^>]*>/i', $this->value)) {
// If it's just one or two tags on its own (and not the above) it's empty. This might be <p></p> or <h1></h1> or whatever. return true;
if(preg_match('/^[\\s]*(<[^>]+>[\\s]*){1,2}$/', $this->value)) return false; }
// If it's just one or two tags on its own (and not the above) it's empty.
// This might be <p></p> or <h1></h1> or whatever.
if(preg_match('/^[\\s]*(<[^>]+>[\\s]*){1,2}$/', $this->value)) {
return false;
}
// Otherwise its content is genuine content // Otherwise its content is genuine content
return true; return true;
} }

View File

@ -426,7 +426,8 @@ class Member extends DataObject implements TemplateGlobalProvider {
Cookie::set('alc_enc', null); // // Clear the Remember Me cookie Cookie::set('alc_enc', null); // // Clear the Remember Me cookie
Cookie::forceExpiry('alc_enc'); Cookie::forceExpiry('alc_enc');
// Switch back to live in order to avoid infinite loops when redirecting to the login screen (if this login screen is versioned) // Switch back to live in order to avoid infinite loops when
// redirecting to the login screen (if this login screen is versioned)
Session::clear('readingMode'); Session::clear('readingMode');
$this->write(); $this->write();