[Home]WikiPatches/PartialUrlFix

UseModWiki | WikiPatches | RecentChanges | Preferences

This patch allows embedding relative URL correctly in the anchor tag. i.e. [Partial URL Fix] - TakOta?

A wrong tag like this:

<a href="http:wiki.pl?WikiPatches/PartialUrlFix">

instead of

<a href="wiki.pl?WikiPatches/PartialUrlFix">

confuses Netscape. (somehow IE interprets this in more flexible fashion.)


*** usemod092/wiki.pl	Sat Apr 21 17:44:10 2001
--- wiki.pl	Fri Jan 18 11:36:25 2002
***************
*** 1417,1422 ****
--- 1417,1423 ----
    }
    # Restricted image URLs so that mailto:foo@bar.gif is not an image
    if ($useImage && ($name =~ /^(http:|https:|ftp:).+\.$ImageExtensions$/)) {
+     $name = $1 if ($name =~ /^https?:(.*)/ && $1 !~ /^\/\//);
      return ("<img src=\"$name\">", $punct);
    }
    return ("<a href=\"$name\">$name</a>", $punct);
***************
*** 1425,1430 ****
--- 1426,1432 ----
  sub StoreBracketUrl {
    my ($url, $text) = @_;
  
+   $url = $1 if ($url =~ /^https?:(.*)/ && $1 !~ /^\/\//);
    if ($text eq "") {
      $text = &GetBracketUrlIndex($url);
    }


Actually that first patch should probably be moved outside those if tests. Like so:
sub UrlLink {
  my ($rawname, $useImage) = @_;
  my ($name, $punct);

  ($name, $punct) = &SplitUrlPunct($rawname);
  $name = $1 if ($name =~ /^https?:(.*)/ && $1 !~ /^\/\//);
This works for me also with unbracketed partial links (like http:/path/file). -- PEZ

UseModWiki | WikiPatches | RecentChanges | Preferences
Edit text of this page | View other revisions | Search MetaWiki
Last edited July 7, 2007 2:49 am by MarkusLude (diff)
Search: