Login | Register
My pages Projects Community openCollabNet

Discussions > dev > a patch for URLs that are not properly URL encoded

maxq
Discussion topic

Back to topic list

a patch for URLs that are not properly URL encoded

Author brianmooreca
Full name Brian Moore
Date 2005-06-21 11:35:28 PDT
Message hello,

i've been using maxq on a site that doesn't properly URL encode
its URLs. while this is incorrect i can't change them, so i've
modified maxq to deal properly with these malformed URLs.

in particular the urls are of the form:
   htp://host:port/foo/bar/baz?q=%
they intended q to hold the string "%" but this is obviously
incorrect. it's a very special case, and i don't know if you'd
like to take the patch or not, but i'm providing it in case
you'd like to take it. please find it attached and below,

b

--- before Tue Jun 21 11:10:28 2005
+++ HttpTestCase.java Mon Jun 20 16:32:34 2005
@@ -203,12 +203,18 @@
       for(int count=0; count<s.length(); count++){
         if(s.charAt(count)=='%'){
           count++;
- int a=Character.digit(s.​charAt(count++),16);​
- a=a<<4;
- int b=Character.digit(s.​charAt(count),16);
- // prefix ' (ascii 39) or " (ascii 132) with '\' (ascii 92)
- if ( a+b == 39 || a+b == 132 ) out.write(92);
- out.write(a+b);
+ if(count < s.length()) {
+ int a=Character.digit(s.​charAt(count++),16);​
+ a=a<<4;
+ int b=Character.digit(s.​charAt(count),16);
+ // prefix ' (ascii 39) or " (ascii 132) with '\' (ascii 92)
+ if ( a+b == 39 || a+b == 132 ) out.write(92);
+ out.write(a+b);
+ }
+ else {
+ // pass through a final %
+ out.write('%');
+ }
         }
         else {
           if(s.charAt(count)=='+')


____________________​____________________​__________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
Attachments

« Previous message in topic | 1 of 6 | Next message in topic »

Messages

Show all messages in topic

a patch for URLs that are not properly URL encoded brianmooreca Brian Moore 2005-06-21 11:35:28 PDT
     Re: [maxq-dev] a patch for URLs that are not properly URL encoded oliverbock Oliver Bock 2005-06-21 15:33:39 PDT
         Re: [maxq-dev] a patch for URLs that are not properly URL encoded brianmooreca Brian Moore 2005-06-21 16:15:52 PDT
             Re: [maxq-dev] a patch for URLs that are not properly URL encoded brianmooreca Brian Moore 2005-06-22 00:24:18 PDT
                 Re: [maxq-dev] a patch for URLs that are not properly URL encoded oliverbock Oliver Bock 2005-06-22 00:32:29 PDT
                     Re: [maxq-dev] a patch for URLs that are not properly URL encoded brianmooreca Brian Moore 2005-06-22 09:23:15 PDT
Messages per page: