Enclosed is a patch for the "redirect" tag in WebUtils to improve the
resolution of relative uris.  I hope this is helpful--let me know if
more information is needed or if I need to do something differently.

The first attachment to this message is a comparison of different
algorithms for uri-resolution, including the examples from RFC2396 and
the output of URI.pm.  The column labeled WebUtils0 is from WebUtils
revision 1.5.

I fixed most of the differences between the output of WebUtils and URI.pm
with four changes to the redirect subroutine:
  0. commented out the line adding a leading "./" (why was this needed?)
  1. added missing backslash to "/./" regex
  2. added a while loop around "/./" regex
  3. removed 'g' modifier in while loops
The results of these changes are shown in the column labeled WebUtils1.

However, there were a few remaining differences in the handling of
"/./" and "/../", which I fixed by adding some lines to deal with
leading "/../" and to deal with query strings and fragments (#...).
The results of these changes are shown in the column labeled
WebUtils2.  Note that there is one remaining difference, the case when
the uri consists solely of a fragment, "#s".  But I decided not to
deal with this case since it causes a redirection loop and so no one
should be using it.

The second attachment is the script that produces the
comparisons--feel free to experiment with this script to try other
test cases and to test additional improvements to the uri-resolution
algorithm.  If anyone finds a test case that is not handled properly
let me know and I will try to find a way to handle it.

The third attachment is my patch with the above fixes.  The fourth
attachment is a patch that uses URI.pm directly.  This is the most
straightforward solution, but I assume URI.pm is not being used so
that WebUtils.pm does not have to rely on this extra package being
installed.

Ken

P.S. Soon I am going on vacation until mid-Oct, so I may not be able
to reply to emails during that time.

BASE: /b/c/d;p?q#f
RELATIVE             RFC           URI               WebUtils0      WebUtils1        
WebUtils2        
g                    /b/c/g            /b/c/g        NC: /c/            /b/c/g         
  /b/c/g       
./g                  /b/c/g            /b/c/g        NC: /c/./          /b/c/g         
  /b/c/g       
g/                   /b/c/g/           /b/c/g/       NC: /c/            /b/c/g/        
  /b/c/g/      
/g                   /g                /g                /g             /g             
  /g           
//g                  //g               //g               //g            //g            
  //g          
?y                   /b/c/?y           /b/c/?y       NC: /c/?y          /b/c/?y        
  /b/c/?y      
?y/./x               /b/c/?y/./x       /b/c/?y/./x   NC: /c/?y/x    NC: /b/c/?y/x      
  /b/c/?y/./x  
?y/../x              /b/c/?y/../x      /b/c/?y/../x  NC: /c/        NC: /b/c/x         
  /b/c/?y/../x 
g?y                  /b/c/g?y          /b/c/g?y      NC: /c/g?y         /b/c/g?y       
  /b/c/g?y     
#s                   /b/c/d;p?q#s      /b/c/d;p?q#s  NC: /c/#s      NC: /b/c/#s      
NC: /b/c/#s      
g#s                  /b/c/g#s          /b/c/g#s      NC: /c/g#s         /b/c/g#s       
  /b/c/g#s     
g?y#s                /b/c/g?y#s        /b/c/g?y#s    NC: /c/g?y#s       /b/c/g?y#s     
  /b/c/g?y#s   
;x                   /b/c/;x           /b/c/;x       NC: /c/;x          /b/c/;x        
  /b/c/;x      
g;x                  /b/c/g;x          /b/c/g;x      NC: /c/g;x         /b/c/g;x       
  /b/c/g;x     
g;x?y#s              /b/c/g;x?y#s      /b/c/g;x?y#s  NC: /c/g;x?y#s     /b/c/g;x?y#s   
  /b/c/g;x?y#s 
.                    /b/c/             /b/c/         NC: /c/.           /b/c/          
  /b/c/        
./                   /b/c/             /b/c/         NC: /c/./          /b/c/          
  /b/c/        
..                   /b/               /b/           NC: /              /b/            
  /b/          
../                  /b/               /b/           NC: /              /b/            
  /b/          
../g                 /b/g              /b/g          NC: /              /b/g           
  /b/g         
../..                /                 /                 /              /              
  /            
../../               /                 /                 /              /              
  /            
../../g              /g                /g            NC: /              /g             
  /g           
                     /b/c/d;p?q#f      /b/c/d;p?q#f  NC: /c/        NC: /b/c/          
  /b/c/d;p?q#f 
../../../g           /../g             /../g         NC: /          NC: /g             
  /../g        
../../../../g        /../../g          /../../g      NC: /          NC: /g             
  /../../g     
../../../../g/h/../i /../../g/i        /../../g/i    NC: /          NC: /g/i           
  /../../g/i   
../..g/../h          /b/h              /b/h          NC: /              /b/h           
  /b/h         
/./g                 /./g              /./g              /./g           /./g           
  /./g         
/../g                /../g             /../g             /../g          /../g          
  /../g        
g.                   /b/c/g.           /b/c/g.       NC: /c/g.          /b/c/g.        
  /b/c/g.      
.g                   /b/c/.g           /b/c/.g       NC: /c/.g          /b/c/.g        
  /b/c/.g      
g..                  /b/c/g..          /b/c/g..      NC: /c/g..         /b/c/g..       
  /b/c/g..     
..g                  /b/c/..g          /b/c/..g      NC: /c/..g         /b/c/..g       
  /b/c/..g     
./../g               /b/g              /b/g          NC: /c/            /b/g           
  /b/g         
./g/.                /b/c/g/           /b/c/g/       NC: /c/./.         /b/c/g/        
  /b/c/g/      
g/./h                /b/c/g/h          /b/c/g/h      NC: /c/./          /b/c/g/h       
  /b/c/g/h     
g/../h               /b/c/h            /b/c/h        NC: /              /b/c/h         
  /b/c/h       
g;x=1/./y            /b/c/g;x=1/y      /b/c/g;x=1/y  NC: /c/g;x=1/y     /b/c/g;x=1/y   
  /b/c/g;x=1/y 
g;x=1/../y           /b/c/y            /b/c/y        NC: /c/            /b/c/y         
  /b/c/y       
g?y/./x              /b/c/g?y/./x      /b/c/g?y/./x  NC: /c/g?y/x   NC: /b/c/g?y/x     
  /b/c/g?y/./x 
g?y/../x             /b/c/g?y/../x     /b/c/g?y/../x NC: /c/        NC: /b/c/x         
  /b/c/g?y/../x
g#s/./x              /b/c/g#s/./x      /b/c/g#s/./x  NC: /c/g#s/x   NC: /b/c/g#s/x     
  /b/c/g#s/./x 
g#s/../x             /b/c/g#s/../x     /b/c/g#s/../x NC: /c/        NC: /b/c/x         
  /b/c/g#s/../x
Results marked 'NC:' are not compliant with examples from RFC 2396.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to