From feeffe6ed261bb5fa0cdb1ba15e520e63b9c3cb4 Mon Sep 17 00:00:00 2001 From: "Edward Z. Yang" Date: Fri, 29 Oct 2010 14:47:40 +0100 Subject: [PATCH] Check if schema.ser was corrupted. Signed-off-by: Edward Z. Yang --- NEWS | 1 + library/HTMLPurifier/ConfigSchema.php | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 7a2d4236..c028c486 100644 --- a/NEWS +++ b/NEWS @@ -17,6 +17,7 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier - Escape CDATA before removing Internet Explorer comments. - Fix removal of id attributes under certain conditions by ensuring armor attributes are preserved when recreating tags. +- Check if schema.ser was corrupted. 4.2.0, released 2010-09-15 ! Added %Core.RemoveProcessingInstructions, which lets you remove diff --git a/library/HTMLPurifier/ConfigSchema.php b/library/HTMLPurifier/ConfigSchema.php index 67be5c71..fadf7a58 100644 --- a/library/HTMLPurifier/ConfigSchema.php +++ b/library/HTMLPurifier/ConfigSchema.php @@ -60,7 +60,13 @@ class HTMLPurifier_ConfigSchema { * Unserializes the default ConfigSchema. */ public static function makeFromSerial() { - return unserialize(file_get_contents(HTMLPURIFIER_PREFIX . '/HTMLPurifier/ConfigSchema/schema.ser')); + $contents = file_get_contents(HTMLPURIFIER_PREFIX . '/HTMLPurifier/ConfigSchema/schema.ser'); + $r = unserialize($contents); + if (!$r) { + $hash = sha1($contents); + trigger_error("Unserialization of configuration schema failed, sha1 of file was $hash", E_USER_ERROR); + } + return $r; } /** -- 2.11.4.GIT