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 » Text » Text_Wiki_BBCode » Bug #6100

relative urls don't work right.

Details

Submitted2005-11-28 23:36 UTC
Fromme at ben-xo dot com
Assignedfirman
StatusVerified
PackageText_Wiki_BBCode
PHP Version4.4.0
Roadmaps(Not assigned)

Comments

[2005-11-28 23:36 UTC] me at ben-xo dot com

Description:
------------
Text_Wiki 1.0.3 and Text_Wiki_BBCode 0.0.2

So i figured out how to turn on relative_urls in Url.php (not the easiest thing to figure out because the doc is currently incomplete; - but i worked it out).

Anyway. It doesn't do what i expect.

Looking at the way the regex has been set up, it's completely different from the patch I submitted. Fair enough, as i don't know all the criteria and decision that went into the editing that you did, but still - it doesn't work right (:

Test script:
---------------
[url=/contact]Use this form please.[/url]
[url]/contact[/url]

Expected result:
----------------
<a href="/contact">Use this form please</a>
<a href="/contact">/contact</a>

Actual result:
--------------
<a href="/contact">/contact</a>
<a href="http:///contact">/contact</a>

[2005-11-29 01:42 UTC] me at ben-xo dot com

Wait. I fixed it.

diff -ur Text_Wiki_BBCode-0.0.2/Text/Wiki/Parse/BBCode/Url.php Text_Wiki_BBCode-0.0.2-benxo/Text/Wiki/Parse/BBCode/Url.php
--- Text_Wiki_BBCode-0.0.2/Text/Wiki/Parse/BBCode/Url.php 2005-11-06 06:59:02.000000000 +0000
+++ Text_Wiki_BBCode-0.0.2-benxo/Text/Wiki/Parse/BBCode/Url.php 2005-11-29 01:41:57.000000000 +0000
@@ -52,7 +52,7 @@
'refused' => array('script', 'about', 'applet', 'activex', 'chrome'),
'prefixes' => array('www', 'ftp'),
'host_regexp' => '(?:[^.\s/"\'<\\\#delim#\ca-\cz]+\.)*[a-z](?:[-a-z0-9]*[a-z0-9])?\.?',
- 'path_regexp' => '(?:/[^][\'\s"<\\\#delim#\ca-\cz]*)?',
+ 'path_regexp' => '(?:(/)[^][\'\s"<\\\#delim#\ca-\cz]*)?',
'user_regexp' => '[^]()<>[:;@\,."\s\\\#delim#\ca-\cz]+(?:\.[^]()<>[:;@\,."\s\\\#delim#\ca-\cz]+)*',
'inline_enable' => true,
'relative_enable' => false

[2005-11-29 01:46 UTC] me at ben-xo dot com

That's a bit messy but ...

'(?:/[^][\'\s"<\\\#delim#\ca-\cz]*)?',

becomes

'(?:(/)[^][\'\s"<\\\#delim#\ca-\cz]*)?',

that's the only change.

capturing the (/) has the same effect in the decision login as if it had captured a URL protocol; it bases whether or not it's a URL with a URL link or a URL with a text description link on the number/content of captured subexps.

[2005-11-29 06:00 UTC] me at ben-xo dot com

Disregard my last patch, it breaks other things!

Here is a new one... i have tested with as many examples as i could think of, but i may not have tested it fully

--- Text_Wiki_BBCode-0.0.2/Text/Wiki/Parse/BBCode/Url.php 2005-11-06 06:59:02.000000000 +0000
+++ Text_Wiki_BBCode-0.0.2-benxo/Text/Wiki/Parse/BBCode/Url.php 2005-11-29 05:36:01.000000000 +0000
@@ -52,7 +52,7 @@
'refused' => array('script', 'about', 'applet', 'activex', 'chrome'),
'prefixes' => array('www', 'ftp'),
'host_regexp' => '(?:[^.\s/"\'<\\\#delim#\ca-\cz]+\.)*[a-z](?:[-a-z0-9]*[a-z0-9])?\.?',
- 'path_regexp' => '(?:/[^][\'\s"<\\\#delim#\ca-\cz]*)?',
+ 'path_regexp' => '(?:/()[^][\'\s"<\\\#delim#\ca-\cz]*)?',
'user_regexp' => '[^]()<>[:;@\,."\s\\\#delim#\ca-\cz]+(?:\.[^]()<>[:;@\,."\s\\\#delim#\ca-\cz]+)*',
'inline_enable' => true,
'relative_enable' => false
@@ -156,7 +156,7 @@
$pre = $matches[1];
if (!$matches[2]) {
$matches[2] = 'mailto:' . $matches[3];
- $matches[4] = $matches[3];
+ $matches[5] = $matches[3];
}
}
}
@@ -164,7 +164,7 @@
$options = array(
'type' => $type,
'href' => (isset($matches[3]) ? '' : 'http://') . $matches[2],
- 'text' => isset($matches[4]) ? $matches[4] : $matches[2]
+ 'text' => isset($matches[5]) ? $matches[5] : (!empty($matches[4]) ? $matches[4] : $matches[2])
);

// tokenize