URI::sip(s) does not honor the URI API contract of returning the original URI if it cannot be made absolute in new_abs() or abs(), or relative in rel(). Fix along with a couple of test cases attached.
Index: URI/sip.pm =================================================================== RCS file: /cvsroot/libwww-perl/uri/URI/sip.pm,v retrieving revision 1.2 diff -a -u -r1.2 sip.pm --- URI/sip.pm 5 Aug 2003 15:30:13 -0000 1.2 +++ URI/sip.pm 2 Jun 2004 14:51:33 -0000 @@ -76,11 +76,11 @@ } # Inherited methods that make no sense for a SIP URI. -sub path {}; -sub path_query {}; -sub path_segments {}; -sub abs {}; -sub rel {}; -sub query_keywords {}; +sub path {} +sub path_query {} +sub path_segments {} +sub abs { shift } +sub rel { shift } +sub query_keywords {} 1; Index: t/sip.t =================================================================== RCS file: /cvsroot/libwww-perl/uri/t/sip.t,v retrieving revision 1.3 diff -a -u -r1.3 sip.t --- t/sip.t 5 Aug 2003 15:27:49 -0000 1.3 +++ t/sip.t 2 Jun 2004 14:51:33 -0000 @@ -1,10 +1,11 @@ #!perl -w -print "1..8\n"; +print "1..11\n"; use URI; +use strict; -$u = URI->new('sip:[EMAIL PROTECTED]'); +my $u = URI->new('sip:[EMAIL PROTECTED]'); print "not " unless $u->user eq 'phone' && $u->host eq 'domain.ext' && $u->port eq '5060' && @@ -35,7 +36,7 @@ print "ok 5\n"; $u->query_form(Subject => 'Lunch', Priority => 'Low'); [EMAIL PROTECTED] = $u->query_form; +my @q = $u->query_form; print "not " unless $u->host eq 'domain.ext' && $u->query eq 'Subject=Lunch&Priority=Low' && @q == 4 && "@q" eq "Subject Lunch Priority Low"; @@ -48,10 +49,21 @@ $u = URI->new('sip:[EMAIL PROTECTED]&Priority=Urgent'); $u->params_form(maddr => '127.0.0.1', ttl => '16'); [EMAIL PROTECTED] = $u->params_form; +my @p = $u->params_form; print "not " unless $u->host eq 'domain.ext' && $u->query eq 'Subject=Meeting&Priority=Urgent' && $u->params eq 'maddr=127.0.0.1;ttl=16' && @p == 4 && "@p" eq "maddr 127.0.0.1 ttl 16"; print "ok 8\n"; + +$u = URI->new_abs('sip:[EMAIL PROTECTED]', 'sip:[EMAIL PROTECTED]'); +print "not " unless $u eq 'sip:[EMAIL PROTECTED]'; +print "ok 9\n"; + +$u = URI->new('sip:[EMAIL PROTECTED]'); +print "not " unless $u eq $u->abs('http://www.cpan.org/'); +print "ok 10\n"; + +print "not " unless $u eq $u->rel('http://www.cpan.org/'); +print "ok 11\n";