PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » Networking » Net_URL2 » Bug #7538

URLs without "http" confuse Net_URL

Details

Request #7538URLs without "http" confuse Net_URL
Submitted2006-05-01 21:06 UTC
Fromjbutler at ua dot edu
Assigneddavidc
StatusWont fix
PackageNet_URL2
PHP Version4.3.2
OSRedhat Linux
Roadmaps(Not assigned)

Comments

[2006-05-01 21:06 UTC] jbutler at ua dot edu

Description:
------------
If a URL does not begin with "http" or similar protocol, then Net_URL gets confused. This makes it tricky to use it when, for example, accepting user-suggested URLs entered into a form. Ideally, Net_URL might check to see if it's a valid URL before parsing it.

Test script below was run on the host, http://www.allthingsacoustic.org, which winds up inserted as the server.

Test script:
---------------
<?php include('Net/URL.php');
$url = &new Net_URL('www.goob.com');
?>
<html>
<body>
Protocol...: <?=$url->protocol?>
Server.....: <?=$url->host?>
Port.......: <?=$url->port?>
File/path..: <?=$url->path?>
Full URL...: <?=$url->getUrl()?>
</body>
</html>

Expected result:
----------------
Protocol...:
Server.....: www.goob.com
Port.......:
File/path..:
Full URL...: http://www.goob.com/

Actual result:
--------------
Protocol...: http
Server.....: www.allthingsacoustic.org
Port.......: 80
File/path..: /tifrl/Net_URL/docs/www.goob.com
Full URL...: http://www.allthingsacoustic.org/tifrl/Net_URL/docs/www.goob.com