Index: trunk/tests/AppTest.php
===================================================================
--- trunk/tests/AppTest.php	(revision 480)
+++ trunk/tests/AppTest.php	(revision 541)
@@ -112,7 +112,7 @@
     function test_printraisedmessages()
     {
+        $app =& App::getInstance();
         ob_start();
         $this->test_raisemsg();  //had to add this line for phpunit ver. 3.7 ///
-        $app =& App::getInstance();
         $app->printraisedmessages();
         $result = ob_get_clean();
@@ -145,4 +145,5 @@
     {
         $app =& App::getInstance();
+        $app->setParam(array('session_use_trans_sid' => true));
         ob_start();
         $app->printhiddensession();
Index: trunk/tests/AuthSQLTest.php
===================================================================
--- trunk/tests/AuthSQLTest.php	(revision 480)
+++ trunk/tests/AuthSQLTest.php	(revision 541)
@@ -71,4 +71,7 @@
         ");
         $_SESSION = AuthSQLTest::$shared_session;
+
+        // Sessions require client IP addr.
+        $_SERVER['REMOTE_ADDR'] = '127.0.0.1';
     }
 
@@ -206,33 +209,41 @@
     function test_generatepassword()
     {
-        $result = $this->Auth_SQL->generatepassword('xCVcvd');
-        $this->assertRegExp('/[bcdfghjklmnprstvwxzBCDFGHJKLMNPRSTVWXZaeiouyAEIOUY0123456789!@#%&*-=+.?][bcdfghjklmnprstvwxzBCDFGHJKLMNPRSTVWXZ][aeiouyAEIOUY][bcdfghjklmnprstvwxz][aeiouy][0123456789]/', $result, 'Generated password does not match intended pattern');
+        $result = $this->Auth_SQL->generatepassword(10);
+        $this->assertEquals(14, strlen($result));
     }
 
     function test_encryptpassword()
     {
-        $this->Auth_SQL->setParam(array('encryption_type' => Auth_SQL::ENCRYPT_MD5));
-        $result = $this->Auth_SQL->encryptpassword('123');
+        $result = $this->Auth_SQL->encryptpassword('123', null, Auth_SQL::ENCRYPT_MD5);
         $this->assertEquals('202cb962ac59075b964b07152d234b70', $result);
-
-        $this->Auth_SQL->setParam(array('encryption_type' => Auth_SQL::ENCRYPT_MD5_HARDENED));
-        $result = $this->Auth_SQL->encryptpassword('123');
-        $this->assertEquals('c55e4ac608a8768ecd758fab971b0646', $result);
-
-        $this->Auth_SQL->setParam(array('encryption_type' => Auth_SQL::ENCRYPT_SHA1));
-        $result = $this->Auth_SQL->encryptpassword('123');
+        $this->assertTrue($this->Auth_SQL->verifyPassword('123', $result, Auth_SQL::ENCRYPT_MD5));
+
+        $result = $this->Auth_SQL->encryptpassword('123', null, Auth_SQL::ENCRYPT_MD5_HARDENED);
+        $this->assertEquals('1f0f8d357a96eb97f24371ebf53dcaf6', $result);
+        $this->assertTrue($this->Auth_SQL->verifyPassword('123', $result, Auth_SQL::ENCRYPT_MD5_HARDENED));
+
+        $result = $this->Auth_SQL->encryptpassword('123', null, Auth_SQL::ENCRYPT_SHA1);
         $this->assertEquals('40bd001563085fc35165329ea1ff5c5ecbdbbeef', $result);
-
-        $this->Auth_SQL->setParam(array('encryption_type' => Auth_SQL::ENCRYPT_SHA1_HARDENED));
-        $result = $this->Auth_SQL->encryptpassword('123');
-        $this->assertEquals('33d90af96a5928ac93cbd41fc436e8c55d2768c2', $result);
-
-        $this->Auth_SQL->setParam(array('encryption_type' => Auth_SQL::ENCRYPT_PLAINTEXT));
-        $result = $this->Auth_SQL->encryptpassword('123');
+        $this->assertTrue($this->Auth_SQL->verifyPassword('123', $result, Auth_SQL::ENCRYPT_SHA1));
+
+        $result = $this->Auth_SQL->encryptpassword('123', null, Auth_SQL::ENCRYPT_SHA1_HARDENED);
+        $this->assertEquals('1d086fcae3dd941e0f1371148502d03e96ab536f', $result);
+        $this->assertTrue($this->Auth_SQL->verifyPassword('123', $result, Auth_SQL::ENCRYPT_SHA1_HARDENED));
+
+        $result = $this->Auth_SQL->encryptpassword('123', null, Auth_SQL::ENCRYPT_PLAINTEXT);
         $this->assertEquals('123', $result);
-
-        $this->Auth_SQL->setParam(array('encryption_type' => Auth_SQL::ENCRYPT_CRYPT));
-        $result = $this->Auth_SQL->encryptpassword('123', 'saltstring');
-        $this->assertEquals('saEZ6MlWYV9nQ', $result);
+        $this->assertTrue($this->Auth_SQL->verifyPassword('123', $result, Auth_SQL::ENCRYPT_PLAINTEXT));
+
+        $result = $this->Auth_SQL->encryptpassword('123', 'saltstring', Auth_SQL::ENCRYPT_CRYPT);
+        $this->assertTrue($this->Auth_SQL->verifyPassword('123', $result, Auth_SQL::ENCRYPT_CRYPT));
+
+        if (function_exists('password_hash')) {
+            // Only available in PHP >= 5.5
+            $result = $this->Auth_SQL->encryptpassword('123', 'saltstring', Auth_SQL::ENCRYPT_PASSWORD_BCRYPT);
+            $this->assertTrue($this->Auth_SQL->verifyPassword('123', $result, Auth_SQL::ENCRYPT_PASSWORD_BCRYPT));
+
+            $result = $this->Auth_SQL->encryptpassword('123', 'saltstring', Auth_SQL::ENCRYPT_PASSWORD_DEFAULT);
+            $this->assertTrue($this->Auth_SQL->verifyPassword('123', $result, Auth_SQL::ENCRYPT_PASSWORD_DEFAULT));
+        }
     }
 
@@ -241,5 +252,5 @@
         $db =& DB::getInstance();
 
-        $this->Auth_SQL->setParam(array('encryption_type' => Auth_SQL::ENCRYPT_SHA1_HARDENED));
+        $this->Auth_SQL->setParam(array('hash_type' => Auth_SQL::ENCRYPT_SHA1_HARDENED));
         $this->Auth_SQL->setpassword(null, '123');
         $qid = $db->query("
@@ -248,5 +259,5 @@
         ");
         list($pass) = mysql_fetch_row($qid);
-        $this->assertEquals('33d90af96a5928ac93cbd41fc436e8c55d2768c2', $pass);
+        $this->assertEquals('1d086fcae3dd941e0f1371148502d03e96ab536f', $pass);
     }
 
Index: trunk/tests/Auth_SQLTest.php
===================================================================
--- trunk/tests/Auth_SQLTest.php	(revision 480)
+++ 	(revision )
@@ -1,262 +1,0 @@
-<?php
-/**
- * The Strangecode Codebase - a general application development framework for PHP
- * For details visit the project site: <http://trac.strangecode.com/codebase/>
- * Copyright 2001-2012 Strangecode, LLC
- *
- * This file is part of The Strangecode Codebase.
- *
- * The Strangecode Codebase is free software: you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as published by the
- * Free Software Foundation, either version 3 of the License, or (at your option)
- * any later version.
- *
- * The Strangecode Codebase is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/**
- * PHPUnit test case for codebase/lib/Auth_SQL.inc.php
- *
- * The method skeletons below need to be filled in with
- * real data so that the tests will run correctly. Replace
- * all EXPECTED_VAL and PARAM strings with real data.
- *
- * Created with PHPUnit_Skeleton on 2005-08-09
- */
-
-class Auth_SQLTest extends PHPUnit_TestCase {
-
-    var $Auth_SQL;
-
-    function Auth_SQLTest($name)
-    {
-        $this->PHPUnit_TestCase($name);
-    }
-
-    function setUp()
-    {
-        require dirname(__FILE__) . '/_config.inc.php';
-        require_once '../lib/Auth_SQL.inc.php';
-        $this->Auth_SQL =& new Auth_SQL('testauth');
-        $this->Auth_SQL->setParam(array(
-            'db_table'          => 'test_user_tbl',
-            'db_primary_key'    => 'user_id',
-            'db_login_table'    => 'test_login_tbl',
-            'login_url'         => '/login.php',
-            'blocking'          => true,
-            'encryption_type' => Auth_SQL::ENCRYPT_MD5_HARDENED,
-        ));
-
-        // Use fresh user table.
-        $this->Auth_SQL->initDB(true);
-
-        // Insert test data.
-        $db =& DB::getInstance();
-        $db->query("
-            INSERT INTO test_user_tbl (
-                username,
-                userpass,
-                first_name,
-                last_name,
-                email
-            ) VALUES (
-                'testuser',
-                '" . $this->Auth_SQL->encryptPassword('testpass') . "',
-                'John',
-                'Doe',
-                'root@localhost'
-            )
-        ");
-
-    }
-
-    function tearDown()
-    {
-        $db =& DB::getInstance();
-
-        unset($this->Auth_SQL);
-        $db->query("DROP TABLE IF EXISTS test_user_tbl");
-        $db->query("DROP TABLE IF EXISTS test_login_tbl");
-    }
-
-    function test_set()
-    {
-        $this->Auth_SQL->set('testuserkey', 'testuserval');
-        $this->assertEquals('testuserval', $_SESSION['_auth_sql'][$this->Auth_SQL->_ns]['user_data']['testuserkey']);
-    }
-
-    function test_get()
-    {
-        $_SESSION['_auth_sql'][$this->Auth_SQL->_ns]['user_data']['testuserkey'] = 'testuserval';
-        $val = $this->Auth_SQL->get('testuserkey');
-        $this->assertEquals('testuserval', $val);
-    }
-
-    function test_setparam()
-    {
-        $this->Auth_SQL->setParam(array(
-            'login_url'         => 'testloginurl.php'
-        ));
-        $this->assertEquals('testloginurl.php', $this->Auth_SQL->_params['login_url']);
-    }
-
-    function test_getparam()
-    {
-        $this->Auth_SQL->_params['login_url'] = 'testloginurl.php';
-        $param = $this->Auth_SQL->getParam('login_url');
-        $this->assertEquals('testloginurl.php', $param);
-    }
-
-    function test_clear()
-    {
-        $login = $this->Auth_SQL->login('testuser', 'testpass');
-        $this->assertTrue($login, 'User login failed, but should have succeeded.');
-        $before_logged_in = $this->Auth_SQL->isloggedin();
-        $this->assertTrue($before_logged_in, 'User is not logged in, but should be.');
-        $this->Auth_SQL->clear();
-        $after_logged_in = $this->Auth_SQL->isloggedin();
-        $this->assertFalse($after_logged_in, 'User is still logged in but should not be.');
-    }
-
-    function test_authenticate()
-    {
-        $true = $this->Auth_SQL->authenticate('testuser', 'testpass');
-        $this->assertTrue($true, 'User login failed, but should have succeeded.');
-
-        // Testing wrong password.
-        $false = $this->Auth_SQL->authenticate('testuser', 'wrongpass');
-
-        $this->assertfalse($false, 'User login succeeded, but should have failed.');
-    }
-
-    function test_login_and_isLoggedIn()
-    {
-        $login = $this->Auth_SQL->login('testuser', 'testpass');
-        $this->assertTrue($login, '1. User login failed, but should have succeeded.');
-        $before_logged_in = $this->Auth_SQL->isloggedin();
-        $this->assertTrue($before_logged_in, '2. User is not logged in, but should be.');
-        $this->Auth_SQL->clear();
-        $after_logged_in = $this->Auth_SQL->isloggedin();
-        $this->assertFalse($after_logged_in, '3. User is still logged in but should not be.');
-
-        // Testing wrong password.
-        $login2 = $this->Auth_SQL->login('testuser', 'wrongpass');
-        $this->assertFalse($login2, '4. User login succeeded, but should have failed.');
-        $before_logged_in2 = $this->Auth_SQL->isloggedin();
-        $this->assertFalse($before_logged_in2, '5. User is logged in, but should not be.');
-        $this->Auth_SQL->clear();
-        $after_logged_in2 = $this->Auth_SQL->isloggedin();
-        $this->assertFalse($after_logged_in2, '6. Wrong user is still logged in but should not be.');
-    }
-
-    function test_requirelogin()
-    {
-//         $this->Auth_SQL->requirelogin('Login is required!');
-    }
-
-    function test_blockaccount()
-    {
-        $db =& DB::getInstance();
-
-        $this->Auth_SQL->login('testuser', 'testpass');
-        $this->Auth_SQL->blockaccount(null, 'blocktestuser');
-        $qid = $db->query("
-            SELECT blocked_reason
-            FROM test_user_tbl
-        ");
-        list($reason) = mysql_fetch_row($qid);
-        $this->assertEquals('blocktestuser', $reason, "Block not found in DB record.");
-    }
-
-    function test_unblockaccount()
-    {
-        $db =& DB::getInstance();
-
-        $db->query("
-            UPDATE test_user_tbl SET blocked_reason = 'blocktestuser'
-        ");
-        $this->Auth_SQL->unblockaccount();
-
-        $qid = $db->query("
-            SELECT blocked_reason
-            FROM test_user_tbl
-        ");
-        list($reason) = mysql_fetch_row($qid);
-        $this->assertTrue('' == $reason, "Block not removed from DB record.");
-    }
-
-    function test_usernameexists()
-    {
-        $result = $this->Auth_SQL->usernameexists('testuser');
-        $this->assertTrue($result);
-    }
-
-    function test_getusername()
-    {
-        $result = $this->Auth_SQL->getusername(1);
-        $this->assertEquals('testuser', $result);
-    }
-
-    function test_generatepassword()
-    {
-        $result = $this->Auth_SQL->generatepassword('xCVcvd');
-        $this->assertRegExp('/[bcdfghjklmnprstvwxzBCDFGHJKLMNPRSTVWXZaeiouyAEIOUY0123456789][bcdfghjklmnprstvwxzBCDFGHJKLMNPRSTVWXZ][aeiouyAEIOUY][bcdfghjklmnprstvwxz][aeiouy][0123456789]/', $result, 'Generated password does not match intended pattern');
-    }
-
-    function test_encryptpassword()
-    {
-        $this->Auth_SQL->setParam(array('encryption_type' => Auth_SQL::ENCRYPT_MD5));
-        $result = $this->Auth_SQL->encryptpassword('123');
-        $this->assertEquals('202cb962ac59075b964b07152d234b70', $result);
-
-        $this->Auth_SQL->setParam(array('encryption_type' => Auth_SQL::ENCRYPT_MD5_HARDENED));
-        $result = $this->Auth_SQL->encryptpassword('123');
-        $this->assertEquals('c55e4ac608a8768ecd758fab971b0646', $result);
-
-        $this->Auth_SQL->setParam(array('encryption_type' => Auth_SQL::ENCRYPT_SHA1));
-        $result = $this->Auth_SQL->encryptpassword('123');
-        $this->assertEquals('40bd001563085fc35165329ea1ff5c5ecbdbbeef', $result);
-
-        $this->Auth_SQL->setParam(array('encryption_type' => Auth_SQL::ENCRYPT_SHA1_HARDENED));
-        $result = $this->Auth_SQL->encryptpassword('123');
-        $this->assertEquals('33d90af96a5928ac93cbd41fc436e8c55d2768c2', $result);
-
-        $this->Auth_SQL->setParam(array('encryption_type' => Auth_SQL::ENCRYPT_PLAINTEXT));
-        $result = $this->Auth_SQL->encryptpassword('123');
-        $this->assertEquals('123', $result);
-
-        $this->Auth_SQL->setParam(array('encryption_type' => Auth_SQL::ENCRYPT_CRYPT));
-        $result = $this->Auth_SQL->encryptpassword('123', 'saltstring');
-        $this->assertEquals('saEZ6MlWYV9nQ', $result);
-    }
-
-    function test_setpassword()
-    {
-        $db =& DB::getInstance();
-
-        $this->Auth_SQL->setParam(array('encryption_type' => Auth_SQL::ENCRYPT_SHA1_HARDENED));
-        $this->Auth_SQL->setpassword(null, '123');
-        $qid = $db->query("
-            SELECT userpass
-            FROM test_user_tbl
-        ");
-        list($pass) = mysql_fetch_row($qid);
-        $this->assertEquals('33d90af96a5928ac93cbd41fc436e8c55d2768c2', $pass);
-    }
-
-    function test_resetpassword()
-    {
-        $result = $this->Auth_SQL->resetpassword(1, 'Because this is a test.');
-        $this->assertType('array', $result);
-    }
-}
-// Running the test.
-$suite = new PHPUnit_TestSuite('Auth_SQLTest');
-$result = PHPUnit::run($suite);
-echo $result->toString();
Index: trunk/tests/LockTest.php
===================================================================
--- trunk/tests/LockTest.php	(revision 480)
+++ trunk/tests/LockTest.php	(revision 541)
@@ -4,5 +4,5 @@
  * For details visit the project site: <http://trac.strangecode.com/codebase/>
  * Copyright 2001-2012 Strangecode, LLC
- * 
+ *
  * This file is part of The Strangecode Codebase.
  *
@@ -11,10 +11,10 @@
  * Free Software Foundation, either version 3 of the License, or (at your option)
  * any later version.
- * 
+ *
  * The Strangecode Codebase is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  * details.
- * 
+ *
  * You should have received a copy of the GNU General Public License along with
  * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>.
@@ -37,5 +37,5 @@
 
     function setUp()
-    {   
+    {
         require dirname(__FILE__) . '/_config.inc.php';
         require_once '../lib/Lock.inc.php';
@@ -71,4 +71,8 @@
             )
         ");
+
+        // Sessions require client IP addr.
+        $_SERVER['REMOTE_ADDR'] = '127.0.0.1';
+
         $this->Auth_SQL->login('testuser', 'testpass');
 
@@ -87,5 +91,5 @@
     {
         $db =& DB::getInstance();
-    
+
         unset($this->Lock);
         unset($this->Auth_SQL);
Index: trunk/tests/UtilitiesTest.php
===================================================================
--- trunk/tests/UtilitiesTest.php	(revision 480)
+++ trunk/tests/UtilitiesTest.php	(revision 541)
@@ -1,11 +1,8 @@
 <?php
-/// FIXME: Tests not implemented.
-return;
-
 /**
  * The Strangecode Codebase - a general application development framework for PHP
  * For details visit the project site: <http://trac.strangecode.com/codebase/>
  * Copyright 2001-2012 Strangecode, LLC
- * 
+ *
  * This file is part of The Strangecode Codebase.
  *
@@ -14,10 +11,10 @@
  * Free Software Foundation, either version 3 of the License, or (at your option)
  * any later version.
- * 
+ *
  * The Strangecode Codebase is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  * details.
- * 
+ *
  * You should have received a copy of the GNU General Public License along with
  * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>.
@@ -36,21 +33,94 @@
 class UtilitiesTest extends PHPUnit_Framework_TestCase {
 
-    var $Utilities;
-
-    function UtilitiesTest($name)
-    {
-        $this->PHPUnit_Framework_TestCase($name);
-    }
-
     function setUp()
     {
+        define('_CLI', true);
         require dirname(__FILE__) . '/_config.inc.php';
         require_once '../lib/Utilities.inc.php';
-        $this->Utilities =& new Utilities(PARAM);
+        // $this->Utilities =& new Utilities(PARAM);
     }
 
     function tearDown()
     {
-        unset($this->Utilities);
+        $app =& App::getInstance();
+        $app->stop();
+    }
+
+    function test_hyperlinkTxt()
+    {
+        $urls = [
+            ' http://www.asdf.com/ ' => ' <a href="http://www.asdf.com/">www.asdf.com/</a> ',
+            ' www.asdf.com/ ' => ' <a href="http://www.asdf.com/">www.asdf.com/</a> ',
+            ' www.asdf.com/? ' => ' <a href="http://www.asdf.com/">www.asdf.com/</a>? ',
+            ' www.asdf.com/?x=y+z ' => ' <a href="http://www.asdf.com/?x=y+z">www.asdf.com/?x=y+z</a> ',
+            ' www.asdf.com/?x=y+ ' => ' <a href="http://www.asdf.com/?x=y+">www.asdf.com/?x=y+</a> ',
+            ' www.asdf.com/?x= ' => ' <a href="http://www.asdf.com/?x=">www.asdf.com/?x=</a> ',
+            ' www.asdf.com/?x ' => ' <a href="http://www.asdf.com/?x">www.asdf.com/?x</a> ',
+            ' www.asdf.com/?â€ïž=ð¥ ' => ' <a href="http://www.asdf.com/?â€ïž=ð¥">www.asdf.com/?â€ïž=ð¥</a> ',
+            ' www.asdf.com? ' => ' <a href="http://www.asdf.com">www.asdf.com</a>? ',
+            ' www.asdf.com! ' => ' <a href="http://www.asdf.com">www.asdf.com</a>! ',
+            ' www.asdf.com. ' => ' <a href="http://www.asdf.com">www.asdf.com</a>. ',
+            ' `www.asdf.com` ' => ' `www.asdf.com` ',
+            ' "www.asdf.com" ' => ' "www.asdf.com" ',
+            ' <www.asdf.com> ' => ' <<a href="http://www.asdf.com">www.asdf.com</a>> ',
+            ' <http://www.asdf.com> ' => ' <<a href="http://www.asdf.com">www.asdf.com</a>> ',
+            ' (http://www.asdf.com) ' => ' (<a href="http://www.asdf.com">www.asdf.com</a>) ',
+            ' (URL: http://www.asdf.com#1) ' => ' (URL: <a href="http://www.asdf.com#1">www.asdf.com#1</a>) ',
+            ' <a href="http://www.example.com/">Click Here</a> ' => ' <a href="http://www.example.com/">Click Here</a> ',
+            ' <a href="http://www.example.com/">http://www.example.com/</a> ' => ' <a href="http://www.example.com/">http://www.example.com/</a> ',
+            ' <a href=http://www.example.com/>http://www.example.com/</a> ' => ' <a href=http://www.example.com/>http://www.example.com/</a> ',
+            ' <a href=\'http://www.example.com/\' >http://www.example.com/</a> ' => ' <a href=\'http://www.example.com/\' >http://www.example.com/</a> ',
+            ' http://foo.com/blah_blah ' => ' <a href="http://foo.com/blah_blah">foo.com/blah_blah</a> ',
+            ' http://foo.com/blah_blah/ ' => ' <a href="http://foo.com/blah_blah/">foo.com/blah_blah/</a> ',
+            ' http://foo.com/blah_blah_(wikipedia) ' => ' <a href="http://foo.com/blah_blah_(wikipedia">foo.com/blah_blah_(wikipedia</a>) ',
+            ' http://foo.com/blah_blah_(wikipedia)_(again) ' => ' <a href="http://foo.com/blah_blah_(wikipedia)_(again">foo.com/blah_blah_(wikipedia)_(again</a>) ',
+            ' http://www.example.com/wpstyle/?p=364 ' => ' <a href="http://www.example.com/wpstyle/?p=364">www.example.com/wpstyle/?p=364</a> ',
+            ' https://www.example.com/foo/?bar=baz&inga=42&quux ' => ' <a href="https://www.example.com/foo/?bar=baz&amp;inga=42&amp;quux">www.example.com/foo/?bar=baz&inga=42&quux</a> ',
+            ' http://âªdf.ws/123 ' => ' <a href="http://âªdf.ws/123">âªdf.ws/123</a> ',
+            ' http://userid:password@example.com:8080 ' => ' <a href="http://userid:password@example.com:8080">userid:password@example.com:8080</a> ',
+            ' http://userid:password@example.com:8080/ ' => ' <a href="http://userid:password@example.com:8080/">userid:password@example.com:8080/</a> ',
+            ' http://userid@example.com ' => ' <a href="http://userid@example.com">userid@example.com</a> ',
+            ' http://userid@example.com/ ' => ' <a href="http://userid@example.com/">userid@example.com/</a> ',
+            ' http://userid@example.com:8080 ' => ' <a href="http://userid@example.com:8080">userid@example.com:8080</a> ',
+            ' http://userid@example.com:8080/ ' => ' <a href="http://userid@example.com:8080/">userid@example.com:8080/</a> ',
+            ' http://userid:password@example.com ' => ' <a href="http://userid:password@example.com">userid:password@example.com</a> ',
+            ' http://userid:password@example.com/ ' => ' <a href="http://userid:password@example.com/">userid:password@example.com/</a> ',
+            ' http://142.42.1.1/ ' => ' <a href="http://142.42.1.1/">142.42.1.1/</a> ',
+            ' http://142.42.1.1:8080/ ' => ' <a href="http://142.42.1.1:8080/">142.42.1.1:8080/</a> ',
+            ' http://â¡.ws/äš¹ ' => ' <a href="http://â¡.ws/äš¹">â¡.ws/äš¹</a> ',
+            ' http://â.ws ' => ' <a href="http://â.ws">â.ws</a> ',
+            ' http://â.ws/ ' => ' <a href="http://â.ws/">â.ws/</a> ',
+            ' http://foo.com/blah_(wikipedia)#cite-1 ' => ' <a href="http://foo.com/blah_(wikipedia)#cite-1">foo.com/blah_(wikipedia)#cite-1</a> ',
+            ' http://foo.com/blah_(wikipedia)_blah#cite-1 ' => ' <a href="http://foo.com/blah_(wikipedia)_blah#cite-1">foo.com/blah_(wikipedia)_blah#cite-1</a> ',
+            ' http://foo.com/unicode_(âª)_in_parens ' => ' <a href="http://foo.com/unicode_(âª)_in_parens">foo.com/unicode_(âª)_in_parens</a> ',
+            ' http://foo.com/(something)?after=parens ' => ' <a href="http://foo.com/(something)?after=parens">foo.com/(something)?after=parens</a> ',
+            ' http://âº.damowmow.com/ ' => ' <a href="http://âº.damowmow.com/">âº.damowmow.com/</a> ',
+            ' http://code.google.com/events/#&product=browser ' => ' <a href="http://code.google.com/events/#&amp;product=browser">code.google.com/events/#&product=browser</a> ',
+            ' http://j.mp ' => ' <a href="http://j.mp">j.mp</a> ',
+            ' ftp://foo.bar/baz ' => ' <a href="ftp://foo.bar/baz">foo.bar/baz</a> ',
+            ' http://foo.bar/?q=Test%20URL-encoded%20stuff ' => ' <a href="http://foo.bar/?q=Test%20URL-encoded%20stuff">foo.bar/?q=Test%20URL-encoded%20stuff</a> ',
+            ' http://Ù
+Ø«Ø§Ù.Ø¥Ø®ØªØšØ§Ø± ' => ' <a href="http://Ù
+Ø«Ø§Ù.Ø¥Ø®ØªØšØ§Ø±">Ù
+Ø«Ø§Ù.Ø¥Ø®ØªØšØ§Ø±</a> ',
+            ' http://äŸå­.æµè¯ ' => ' <a href="http://äŸå­.æµè¯">äŸå­.æµè¯</a> ',
+            ' http://à€à€Šà€Ÿà€¹à€°à€£.à€ªà€°à¥à€à¥à€·à€Ÿ ' => ' <a href="http://à€à€Šà€Ÿà€¹à€°à€£.à€ªà€°à¥à€à¥à€·à€Ÿ">à€à€Šà€Ÿà€¹à€°à€£.à€ªà€°à¥à€à¥à€·à€Ÿ</a> ',
+            ' http://-.~_!$&\'()*+,;=:%40:80%2f::::::@example.com ' => ' <a href="http://-.~_!$&amp;&#039;()*+,;=:%40:80%2f::::::@example.com">-.~_!$&\'()*+,;=:%40:80%2f::::::@example.com</a> ',
+            ' http://1337.net ' => ' <a href="http://1337.net">1337.net</a> ',
+            ' http://a.b-c.de ' => ' <a href="http://a.b-c.de">a.b-c.de</a> ',
+            ' http://223.255.255.254 ' => ' <a href="http://223.255.255.254">223.255.255.254</a> ',
+            ' http://x and.co OK?' => ' http://x and.co OK?',
+            ' http://foo.bar?q=Spaces should be encoded ' => ' <a href="http://foo.bar?q=Spaces">foo.bar?q=Spaces</a> should be encoded ',
+            ' https://github.com/search?utf8=â&q=gif ' => ' <a href="https://github.com/search?utf8=â&amp;q=gif">github.com/search?utf8=â&q=gif</a> ',
+            ' https://github.com/search?q=gif&utf8=* ' => ' <a href="https://github.com/search?q=gif&amp;utf8=*">github.com/search?q=gif&utf8=*</a> ',
+            ' https://github.com/search?q=gif&utf8=â ' => ' <a href="https://github.com/search?q=gif&amp;utf8=â">github.com/search?q=gif&utf8=â</a> ',
+
+            // These are allowed to fuckup due to limitations in our ability to be omnipotent.
+            ' <a href=http://www.example.com/ > http://www.example.com/</a> ' => ' <a href=http://www.example.com/ > <a href="http://www.example.com/">www.example.com/</a></a> ',
+        ];
+        foreach ($urls as $input => $expected) {
+            $result = hyperlinkTxt($input, false);
+            $this->assertEquals($expected, $result, sprintf('Failed with input: %s', $input));
+        }
     }
 
Index: trunk/tests/phpunit.xml
===================================================================
--- trunk/tests/phpunit.xml	(revision 480)
+++ trunk/tests/phpunit.xml	(revision 541)
@@ -34,4 +34,5 @@
             <file>PayPalTest.php</file>
             <file>VersionTest.php</file>
+            <file>UtilitiesTest.php</file>
         </testsuite>
     </testsuites>
Index: trunk/tests/run_tests.sh
===================================================================
--- trunk/tests/run_tests.sh	(revision 480)
+++ trunk/tests/run_tests.sh	(revision 541)
@@ -31,3 +31,3 @@
 # Config options go in phpunit.xml
 # phpunit --tap | grep -v '^ok '
-phpunit --stderr
+phpunit --stderr || echo "Something went wrong (if there is no output above, check the php_error_log)";
