Further enhancements to the URL module

Tim Bunce (Tim.Bunce@ig.co.uk)
Tue, 21 Mar 1995 01:53:40 +0000


----------
X-Sun-Data-Type: text
X-Sun-Data-Description: text
X-Sun-Data-Name: text
X-Sun-Content-Lines: 89

I've taken Martijn's patch to my Friday evening URL.pm and spent a whole
bunch more hours bashing the escaping and testing into shape.

This is now looking rather good (IMHO ;-)

Some highlights:

	sub escape_test {
	    print "escape_test:\n";
	
	    # supply escaped URL
	    $url = new URI::URL 'http://web/this%20has%20spaces';
	    # check component is unescaped
	    $url->_expect('path', '/this has spaces');
	
	    # modify the unescaped form
	    $url->path('this ALSO has spaces');
	    # check whole url is escaped
	    $url->_expect('str', 'http://web/this%20ALSO%20has%20spaces');
	
	    # now make 'A' an unsafe character :-)
	    $url->unsafe('A\x00-\x20"#%;<>?\x7F-\xFF');
	    $url->_expect('str', 'http://web/this%20%41LSO%20has%20spaces');
	
	    $url = new URI::URL uri_escape('http://web/this % needs escaping');
	    $url->_expect('str', 'http://web/this%20%25%20needs%20escaping');
	
	    my $all = pack('c*',0..255);
	    my $esc = uri_escape($all);
	    my $new = uri_unescape($esc);
	    die "uri_escape->uri_unescape mismatch" unless $all eq $new;
	}