note 93037 deleted from function.parse-url by mazzanet
| From: | mazzanet@php.net | Date: | Thu, 20 Aug 2009 13:42:59 +0000 |
| Subject: | note 93037 deleted from function.parse-url by mazzanet | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-159693@lists.php.net to get a copy of this message | ||
Note Submitter: antispamlol at arcor dot de
----
be sure to use trim($url) before using parse_url($url) when your script is handling with userinput.
<?php
$url = $_POST['url']; // If $_POST['url'] would be "http://php.net" everything would be fine.
// What if it is " http://php.net" (Watch the space in front of the url!)?
$urlcontents = parse_url($url, PHP_URL_HOST); // Now $urlcontents Would be "__http"
$url = trim($url);
$urlcontents = parse_url($url, PHP_URL_HOST); // $urlcontents would be "php.net
?>