[Date Index][Thread Index]
[Date Prev][Date Next][Thread Prev][Thread Next]
navbar problem with non-HTTP URLs (patch included)
- From: Dave Plonka <nospam@thanx>
- Date: Fri, 16 Jul 1999 17:22:57 -0500
WML users,
In working with navbars I noticed that it messes up "absolute" URLs
on buttons unless they are use HTTP as in "http://...". I wanted one of
my navbar buttons to go to an *ftp* URL, as in:
<navbar:button ... url=ftp://ftp.my.domain/pub ...>
The root of the problem is in "wml_include/des/navbar.src" which contains
a quick and dirty regexp which decides that a URL is absolute only if it
contains "http". ("navbar.wml" proceeds to tweak the value of what it
thinks are "relative" URLs - which breaks non-http ones.)
I decied to patch "navbar.wml" to "use URI" (a popular perl module) to
properly parse the URL to determine if it is really absolute or relative.
The patch is attached. Note that this patch does *require* that you
install "URI.pm" (see CPAN).
[I'll submit this as a bug using the web form as well, it's just easier
to attach the patch using an MUA.]
Dave
--
plonka@doit.wisc.edu http://net.doit.wisc.edu/~plonka ARS:N9HZF Madison, WI
*** wml_include/des/navbar.src_djp Mon Jun 28 06:12:34 1999
--- wml_include/des/navbar.src Fri Jul 16 16:52:37 1999
***************
*** 376,381 ****
--- 376,382 ----
</define-tag>
<:
+ use URI;
sub navbar_render {
my($name, $select, $subselected, $txtonly, $nohints, $nbcount) = @_;
***************
*** 458,466 ****
$img[1] = $img[0]
}
for ($i = 0; $i <= $#img; $i++) {
! $img[$i] = "$imgbase/$img[$i]" if ($imgbase ne '' and
! $img[$i] !~ m;^(http://|/););
! $img[$i] = &canonpath($img[$i]) if ($img[$i] !~ m;^http://;);
}
# cleanup url information
--- 459,470 ----
$img[1] = $img[0]
}
for ($i = 0; $i <= $#img; $i++) {
! my $uri = URI->new($img[$i]);
! if (!ref($uri) || '' eq $uri->scheme) {
! # URI has no scheme so it's not an absolute URI reference:
! $img[$i] = "$imgbase/$img[$i]" if ($imgbase ne '');
! $img[$i] = &canonpath($img[$i]);
! }
}
# cleanup url information
***************
*** 468,475 ****
$url = $NAVBAR{"$name"}->{uc($1)};
}
if ($url ne '') {
! $url = "$urlbase/$url" if ($urlbase ne '' and $url !~ m;^(http://|/););
! $url = &canonpath($url) if ($url !~ m;^http://;);
}
# cleanup target information
--- 472,483 ----
$url = $NAVBAR{"$name"}->{uc($1)};
}
if ($url ne '') {
! my $uri = URI->new($url);
! if (!ref($uri) || '' eq $uri->scheme) {
! # URI has no scheme so it's not an absolute URI reference:
! $url = "$urlbase/$url" if ($urlbase ne '');
! $url = &canonpath($url);
! }
}
# cleanup target information