Author: nextgens
Date: 2006-10-15 17:21:03 +0000 (Sun, 15 Oct 2006)
New Revision: 10663

Modified:
   trunk/freenet/src/freenet/keys/FreenetURI.java
Log:
Try to detect URLEncoded freenet URIs and handle them

Modified: trunk/freenet/src/freenet/keys/FreenetURI.java
===================================================================
--- trunk/freenet/src/freenet/keys/FreenetURI.java      2006-10-15 09:23:35 UTC 
(rev 10662)
+++ trunk/freenet/src/freenet/keys/FreenetURI.java      2006-10-15 17:21:03 UTC 
(rev 10663)
@@ -19,6 +19,8 @@
 import freenet.support.HexUtil;
 import freenet.support.IllegalBase64Exception;
 import freenet.support.Logger;
+import freenet.support.URLDecoder;
+import freenet.support.URLEncodedFormatException;
 import freenet.client.InserterException;

 /**
@@ -214,6 +216,7 @@
                if (URI == null) {
                        throw new MalformedURLException("No URI specified");
                }
+               
                // check scheme
                int colon = URI.indexOf(':');
                if ((colon != -1)
@@ -241,6 +244,15 @@
                        URI = URI.substring(0, slash2);
                }

+               int percent = URI.indexOf('%');
+               int slash = URI.indexOf('/');
+               if((percent>-1) && ((percent<slash) || (slash<0))){ /* likely 
to be a copy/pasted url from a browser */
+                       try{
+                               URI=URLDecoder.decode(URI);
+                       }catch(URLEncodedFormatException e){
+                       }
+               }
+               
                // sv is *backwards*
                // this makes for more efficient handling



Reply via email to