PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » HTML » HTML_BBCodeParser » Bug #3932

External URLs are parsed without adding http://

Details

Submitted2005-03-23 16:17 UTC
Fromnic dot rodgers at enableinteractive dot co dot uk
Assignedquipo
StatusClosed
PackageHTML_BBCodeParser
PHP VersionIrrelevant
OSirrelevant
Roadmaps(Not assigned)

Comments

[2005-03-23 16:17 UTC] nic dot rodgers at enableinteractive dot co dot uk

Description:
------------
If the input text includes a web address (containing www.)
then the parsed version adds an anchor tag around the
address but the hrefis missing the http://

Reproduce code:
---------------
require_once('HTML/BBCodeParser.php');

$parser = new HTML_BBCodeParser( array('filters' => 'Basic,Links,Lists') );

$test = 'for more www.test.com some more text';
$out = $parser->qparse($test);
print($out);

Expected result:
----------------
for more <a href='http://www.test.com'>www.test.com</a>
some more text

Actual result:
--------------
for more <a href='www.test.com'>www.test.com</a> some more
text

[2005-09-27 02:23 UTC] seth at pricepages dot org

I've created a new version of the filter Links.php that
fixes Bugs #1388, #1512, #1755, and #3932. It also adds a
few extra things, such as a list of accepted schemes, adding
a trailing slash to the url where appropriate, and removing
trailing whitespace from the file.

Please bang on it and tell me what you think and send me a
testcase/patch if something breaks. Like everyone here, I'd
like this to be bulletproof. Maybe once the maintainer comes
out of hibernation we can get this into the main tree.

One thing that could be fixed is matching anything not
"[url]" or "[url=" brackets in the first preparse regexp.
I'm not sure the best regular expression there.

Here is a link to the updated class:
http://pricepages.org/bbcode/Link.php.zip

[2005-09-27 13:44 UTC] seth at pricepages dot org

Correct URL:
http://pricepages.org/bbcode/Links.php.zip