diff --git a/core/database.class.php b/core/database.class.php index 4ac29bda..f527e208 100644 --- a/core/database.class.php +++ b/core/database.class.php @@ -34,6 +34,7 @@ class Database { require_once "config.php"; $this->db = NewADOConnection($database_dsn); $this->db->SetFetchMode(ADODB_FETCH_ASSOC); + $this->db->Execute("SET NAMES utf8"); // FIXME: mysql specific :| $this->extensions = $this->db->GetAssoc("SELECT name, version FROM extensions"); } else { diff --git a/core/ext/view.ext.php b/core/ext/view.ext.php index 3f5b22ca..9c9548bc 100644 --- a/core/ext/view.ext.php +++ b/core/ext/view.ext.php @@ -26,8 +26,8 @@ class ViewImage extends Extension { $image = $event->get_image(); global $page; - $page->set_title("Image {$image->id}: ".$image->get_tag_list()); - $page->set_heading($image->get_tag_list()); + $page->set_title("Image {$image->id}: ".html_escape($image->get_tag_list())); + $page->set_heading(html_escape($image->get_tag_list())); $page->add_block(new Block("Navigation", $this->build_navigation($image->id), "left", 0)); $page->add_block(new Block("Image", $this->build_image_view($image), "main", 0)); $page->add_block(new Block(null, $this->build_info($image), "main", 10)); diff --git a/core/util.inc.php b/core/util.inc.php index 3e434b62..01902736 100644 --- a/core/util.inc.php +++ b/core/util.inc.php @@ -5,7 +5,7 @@ \* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ function html_escape($input) { - return htmlentities($input); + return htmlentities($input, ENT_QUOTES, "UTF-8"); } function int_escape($input) { diff --git a/ext/upgrade/main.php b/ext/upgrade/main.php index 0abdcc8a..6c21f810 100644 --- a/ext/upgrade/main.php +++ b/ext/upgrade/main.php @@ -60,6 +60,16 @@ class Upgrade extends Extension { $config->set_int("db_version", 5); $config->set_bool("in_upgrade", false); } + + if($config->get_int("db_version") == 5) { + $config->set_bool("in_upgrade", true); + $tables = $database->db->GetCol("SHOW TABLES"); + foreach($tables as $table) { + $database->Execute("ALTER TABLE $table CONVERT TO CHARACTER SET utf8"); + } + $config->set_int("db_version", 6); + $config->set_bool("in_upgrade", false); + } } } add_event_listener(new Upgrade(), 5); diff --git a/install.php b/install.php index 34013583..3be860ab 100644 --- a/install.php +++ b/install.php @@ -447,6 +447,8 @@ function move_data($old_dsn, $new_dsn, $old_data) { function create_tables_mysql($db) { $db->StartTrans(); + $db->Execute("SET NAMES utf8"); // FIXME: mysql-specific :( + $db->Execute("DROP TABLE IF EXISTS aliases"); $db->Execute("CREATE TABLE aliases ( oldtag varchar(255) NOT NULL, diff --git a/themes/default/layout.class.php b/themes/default/layout.class.php index a537cb9c..9eb8c2f0 100644 --- a/themes/default/layout.class.php +++ b/themes/default/layout.class.php @@ -47,6 +47,7 @@ class Layout {