Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 0.0.4

Bug #6100 relative urls don't work right.
Submitted: 2005-11-28 23:36 UTC
From: me at ben-xo dot com Assigned: firman
Status: Verified Package: Text_Wiki_BBCode
PHP Version: 4.4.0 OS:
Roadmaps: (Not assigned)    
Subscription  


 [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>

Comments

 [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
 [2005-11-29 07:02 UTC] toggg
The first case is obviously a bug as we miss the link text. We can certainly consider the second one as also a bug as the link leads then to an external url. The whole "relative" handling was just introduced in this release but is to be reconsidered: * relative can be to the document (not starting with /) or to the server document root (starting with /) * shemes could be optional there (?) Anyway, this extension to relative urls must: * be optional * keep the handling of external urls fully BC