Index: t3lib/class.t3lib_div.php
===================================================================
--- t3lib/class.t3lib_div.php	(revision 5258)
+++ t3lib/class.t3lib_div.php	(working copy)
@@ -676,6 +676,28 @@
 	}
 
 	/**
+	 * Match a given URL with a list of hosts.
+	 *
+	 * @param	string		$url: URL to compare with list of hosts
+	 * @param   string      $list: comma-list of hosts (scheme + hostname + optional path)
+	 * @return	boolean		Whether the URL matches the TYPO3 request host
+	 */
+	public static function cmpHost($url, $list) {
+		$success = false;
+		$list = trim($list);
+		if (!$list)  return false;
+
+		$cmpUrls = explode(',', $list);
+		foreach($cmpUrls as $cmpUrl) {
+			if (stripos($url . '/', $cmpUrl . '/') === 0) {
+				$success = true;
+				break;
+			}
+		}
+		return $success;
+	}
+
+	/**
 	 * Match IP number with list of numbers with wildcard
 	 * Dispatcher method for switching into specialised IPv4 and IPv6 methods.
 	 * Usage: 10
@@ -1551,6 +1573,16 @@
 		return $output;
 	}
 
+	/**
+	 * Checks if a given string is a Uniform Resource Locator (URL).
+	 *
+	 * @param	string		$url: The URL to be validated
+	 * @return	boolean		Whether the given URL is valid
+	 */
+	public static function isValidUrl($url) {
+		return (filter_var($url, FILTER_VALIDATE_URL) !== false);
+	}
+
 
 
 
@@ -3126,7 +3158,7 @@
 
 	/**
 	 * Returns the maximum upload size for a file that is allowed. Measured in KB.
-	 * This might be handy to find out the real upload limit that is possible for this 
+	 * This might be handy to find out the real upload limit that is possible for this
 	 * TYPO3 installation. The first parameter can be used to set something that overrides
 	 * the maxFileSize, usually for the TCA values.
 	 *
Index: tests/t3lib/t3lib_div_testcase.php
===================================================================
--- tests/t3lib/t3lib_div_testcase.php	(revision 5258)
+++ tests/t3lib/t3lib_div_testcase.php	(working copy)
@@ -120,6 +120,110 @@
 			t3lib_div::getBytesFromSizeMeasurement('100g')
 		);
 	}
+
+	/**
+	 * @test
+	 */
+	public function checkisValidURLSucceedsWithWebRessource() {
+		$testUrl = 'http://www.example.org/';
+		$this->assertTrue(t3lib_div::isValidUrl($testUrl));
+	}
+
+	/**
+	 * @test
+	 */
+	public function checkisValidURLSucceedsWithExtentedWebRessource() {
+		$testUrl = 'https://user:pw@www.example.org:80/path?arg=value#fragment';
+		$this->assertTrue(t3lib_div::isValidUrl($testUrl));
+	}
+
+	/**
+	 * @test
+	 */
+	public function checkisValidURLSucceedsWithTelnetRessource() {
+		$testUrl = 'telnet://192.0.2.16:80/';
+		$this->assertTrue(t3lib_div::isValidUrl($testUrl));
+	}
+
+	/**
+	 * @test
+	 */
+	public function checkisValidURLSucceedsWithLdapRessource() {
+		$testUrl = 'ldap://[2001:db8::7]/c=GB?objectClass?one';
+		$this->assertTrue(t3lib_div::isValidUrl($testUrl));
+	}
+
+	/**
+	 * @test
+	 */
+	public function checkisValidURLSucceedsWithFileRessource() {
+		$testUrl = 'file:///etc/passwd';
+		$this->assertTrue(t3lib_div::isValidUrl($testUrl));
+	}
+
+	/**
+	 * @test
+	 */
+	public function checkisValidURLFailsWithHostnameOnly() {
+		$testUrl = 'www.example.org/';
+		$this->assertFalse(t3lib_div::isValidUrl($testUrl));
+	}
+
+	/**
+	 * @test
+	 */
+	public function checkisValidURLFailsWithIPOnly() {
+		$testUrl = '127.0.0.1';
+		$this->assertFalse(t3lib_div::isValidUrl($testUrl));
+	}
+
+	/**
+	 * @test
+	 */
+	public function checkisValidURLFailsWithPathsOnly() {
+		$testUrl = './relpath/file.txt';
+		$this->assertFalse(t3lib_div::isValidUrl($testUrl));
+		$testUrl = '/abspath/file.txt?arg=value';
+		$this->assertFalse(t3lib_div::isValidUrl($testUrl));
+	}
+
+	/**
+	 * @test
+	 */
+	public function checkisValidURLFailsWithArbitraryString() {
+		$testUrl = 'arbitrary string';
+		$this->assertFalse(t3lib_div::isValidUrl($testUrl));
+	}
+
+	/**
+	 * @test
+	 */
+	public function checkCmpHostFailsWithEmptyList() {
+		$testUrl = t3lib_div::getIndpEnv('TYPO3_REQUEST_URL');
+		$this->assertFalse(t3lib_div::cmpHost($testUrl, null));
+		$this->assertFalse(t3lib_div::cmpHost($testUrl, ' '));
+	}
+
+	/**
+	 * @test
+	 */
+	public function checkCmpHostFailsWithDifferentHosts() {
+		$testUrl = t3lib_div::getIndpEnv('TYPO3_REQUEST_URL');
+		$testList = t3lib_div::getIndpEnv('TYPO3_REQUEST_HOST') . '.example.org'
+				  . ',https://www.example.org:443/';
+		$this->assertFalse(t3lib_div::cmpHost($testUrl, $testList));
+	}
+
+	/**
+	 * @test
+	 */
+	public function checkCmpHostSucceedsWithCurrentHost() {
+		$testUrl = t3lib_div::getIndpEnv('TYPO3_REQUEST_URL');
+		$testList = t3lib_div::getIndpEnv('TYPO3_REQUEST_HOST');
+		$this->assertTrue(t3lib_div::cmpHost($testUrl, $testList));
+		$testList = 'a,' . $testList . ',c';
+		$this->assertTrue(t3lib_div::cmpHost($testUrl, $testList));
+	}
 }
 
 ?>
\ No newline at end of file
