diff --git a/include/class.http.php b/include/class.http.php
index 3aea32b6e93029e541bf0d0c9fd28bef15b20dc3..ef917845d76a1f943e022167304eb7a2b0d131c5 100644
--- a/include/class.http.php
+++ b/include/class.http.php
@@ -43,9 +43,14 @@ class Http {
         exit;
     }
 
-	function redirect($url,$delay=0,$msg='') {
+    function redirect($url,$delay=0,$msg='') {
 
-        if(strstr($_SERVER['SERVER_SOFTWARE'], 'IIS')){
+        $iis = strpos($_SERVER['SERVER_SOFTWARE'], 'IIS') !== false;
+        @list($name, $version) = explode('/', $_SERVER['SERVER_SOFTWARE']);
+        // Legacy code for older versions of IIS that would not emit the
+        // correct HTTP status and headers when using the `Location`
+        // header alone
+        if ($iis && version_compare($version, '7.0', '<')) {
             header("Refresh: $delay; URL=$url");
         }else{
             header("Location: $url");
diff --git a/include/class.thread.php b/include/class.thread.php
index 13c2e0dfe5ef1c1f4c463ed83daff8c0c3e53fe4..dfd3bb314a06c982376038ace37ff19ebfea8c67 100644
--- a/include/class.thread.php
+++ b/include/class.thread.php
@@ -744,7 +744,7 @@ Class ThreadEntry {
         $subject = $mailinfo['subject'];
         $match = array();
         if ($subject && $mailinfo['email']
-                && preg_match("/\[#([0-9]{1,10})\]/", $subject, $match)
+                && preg_match("/#[\p{L}-]+?([0-9]{1,10})/u", $subject, $match)
                 && ($tid = Ticket::getIdByExtId((int)$match[1], $mailinfo['email']))
                 )
             // Return last message for the thread
diff --git a/include/mysqli.php b/include/mysqli.php
index 34fa57479b64ebcda7e1ac381f4c70a6069773aa..7245d9ec20eeab75197500a8b9f5d8f06af8e567 100644
--- a/include/mysqli.php
+++ b/include/mysqli.php
@@ -39,18 +39,24 @@ function db_connect($host, $user, $passwd, $options = array()) {
         return NULL;
 
     $port = ini_get("mysqli.default_port");
+    $socket = ini_get("mysqli.default_socket");
     if (strpos($host, ':') !== false) {
-        list($host, $port) = explode(':', $host);
+        list($host, $portspec) = explode(':', $host);
         // PHP may not honor the port number if connecting to 'localhost'
-        if (!strcasecmp($host, 'localhost'))
-            // XXX: Looks like PHP gethostbyname() is IPv4 only
-            $host = gethostbyname($host);
-        $port = (int) $port;
+        if ($portspec && is_numeric($portspec)) {
+            if (!strcasecmp($host, 'localhost'))
+                // XXX: Looks like PHP gethostbyname() is IPv4 only
+                $host = gethostbyname($host);
+            $port = (int) $portspec;
+        }
+        elseif ($portspec) {
+            $socket = $portspec;
+        }
     }
 
     // Connect
     $start = microtime(true);
-    if (!@$__db->real_connect($host, $user, $passwd, null, $port))
+    if (!@$__db->real_connect($host, $user, $passwd, null, $port, $socket))
         return NULL;
 
     //Select the database, if any.
diff --git a/include/upgrader/streams/core/c00511c7-7be60a84.patch.sql b/include/upgrader/streams/core/c00511c7-7be60a84.patch.sql
index e565227249787174009fddfb6e7f06ed82f01d52..97c2bf97b45d6e5fa1368e8011d05e07d48c545e 100644
--- a/include/upgrader/streams/core/c00511c7-7be60a84.patch.sql
+++ b/include/upgrader/streams/core/c00511c7-7be60a84.patch.sql
@@ -224,7 +224,7 @@ CREATE TABLE `%TABLE_PREFIX%email_filter_rule` (
 
 -- SYSTEM BAN LIST was the first filter created, with ID of '1'
 INSERT INTO `%TABLE_PREFIX%email_filter_rule` (`filter_id`, `what`, `how`, `val`)
-    SELECT LAST_INSERT_ID(), 'email', 'equals', email FROM `%TABLE_PREFIX%email_banlist`;
+    SELECT LAST_INSERT_ID(), 'email', 'equal', email FROM `%TABLE_PREFIX%email_banlist`;
 
 -- Create table session
 DROP TABLE IF EXISTS `%TABLE_PREFIX%session`;
diff --git a/setup/inc/class.installer.php b/setup/inc/class.installer.php
index d57fa0b449095e9bb88a1cb3b9004dd0a1325c5a..b43c083da79e297e22a8462b526fc9e3192040f0 100644
--- a/setup/inc/class.installer.php
+++ b/setup/inc/class.installer.php
@@ -81,9 +81,7 @@ class Installer extends SetupWizard {
 
         // Support port number specified in the hostname with a colon (:)
         list($host, $port) = explode(':', $vars['dbhost']);
-        if ($port && (!is_numeric($port) || !((int)$port)))
-            $this->errors['db'] = 'Database port number must be a number';
-        elseif ($port && ($port < 1 || $port > 65535))
+        if ($port && is_numeric($port) && ($port < 1 || $port > 65535))
             $this->errors['db'] = 'Invalid database port number';
 
         //MYSQL: Connect to the DB and check the version & database (create database if it doesn't exist!)