From 6e826bcb8b34d13ac2dc37b8447a5c4ace726849 Mon Sep 17 00:00:00 2001 From: ryan Date: Fri, 26 May 2006 21:09:06 +0000 Subject: [PATCH] base64 cached objects and store within multi-line comment block to avoid CRLF injections into the cache. Props Peter Westwood. git-svn-id: http://svn.automattic.com/wordpress/branches/2.0@3797 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/upgrade.php | 2 +- wp-includes/cache.php | 10 +++++----- wp-includes/version.php | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/wp-admin/upgrade.php b/wp-admin/upgrade.php index 8acbee97c9..88877509fd 100644 --- a/wp-admin/upgrade.php +++ b/wp-admin/upgrade.php @@ -76,7 +76,7 @@ switch($step) { case 1: $wp_current_db_version = __get_option('db_version'); - if ( $wp_db_version < $wp_current_db_version ) { + if ( $wp_db_version != $wp_current_db_version ) { wp_cache_flush(); make_db_current_silent(); upgrade_all(); diff --git a/wp-includes/cache.php b/wp-includes/cache.php index 63a4ce7589..55f4080163 100644 --- a/wp-includes/cache.php +++ b/wp-includes/cache.php @@ -47,8 +47,8 @@ function wp_cache_set($key, $data, $flag = '', $expire = 0) { return $wp_object_cache->set($key, $data, $flag, $expire); } -define('CACHE_SERIAL_HEADER', ""); +define('CACHE_SERIAL_HEADER', ""); class WP_Object_Cache { var $cache_dir; @@ -103,7 +103,7 @@ class WP_Object_Cache { if ( ! $this->acquire_lock() ) return false; - + $this->rm_cache_dir(); $this->cache = array (); $this->dirty_objects = array (); @@ -158,7 +158,7 @@ class WP_Object_Cache { return false; } - $this->cache[$group][$id] = unserialize(substr(@ file_get_contents($cache_file), strlen(CACHE_SERIAL_HEADER), -strlen(CACHE_SERIAL_FOOTER))); + $this->cache[$group][$id] = unserialize(base64_decode(substr(@ file_get_contents($cache_file), strlen(CACHE_SERIAL_HEADER), -strlen(CACHE_SERIAL_FOOTER)))); if (false === $this->cache[$group][$id]) $this->cache[$group][$id] = ''; @@ -342,7 +342,7 @@ class WP_Object_Cache { } $temp_file = tempnam($group_dir, 'tmp'); - $serial = CACHE_SERIAL_HEADER.serialize($this->cache[$group][$id]).CACHE_SERIAL_FOOTER; + $serial = CACHE_SERIAL_HEADER.base64_encode(serialize($this->cache[$group][$id])).CACHE_SERIAL_FOOTER; $fd = @fopen($temp_file, 'w'); if ( false === $fd ) { $errors++; diff --git a/wp-includes/version.php b/wp-includes/version.php index ebe7d6035f..faeb429b25 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -3,6 +3,6 @@ // This just holds the version number, in a separate file so we can bump it without cluttering the SVN $wp_version = '2.0.3-beta'; -$wp_db_version = 3437; +$wp_db_version = 3796; ?>