Author: j16sdiz
Date: 2008-12-19 08:23:18 +0000 (Fri, 19 Dec 2008)
New Revision: 24558

Modified:
   trunk/freenet/src/freenet/clients/http/filter/GenericReadFilterCallback.java
Log:
URI fragment confirming to RFC3986

Modified: 
trunk/freenet/src/freenet/clients/http/filter/GenericReadFilterCallback.java
===================================================================
--- 
trunk/freenet/src/freenet/clients/http/filter/GenericReadFilterCallback.java    
    2008-12-19 08:22:53 UTC (rev 24557)
+++ 
trunk/freenet/src/freenet/clients/http/filter/GenericReadFilterCallback.java    
    2008-12-19 08:23:18 UTC (rev 24558)
@@ -75,8 +75,21 @@
                return processURI(u, overrideType, false, false);
        }
        
+       // RFC3986
+       //  unreserved    = ALPHA / DIGIT / "-" / "." / "_" / "~"
+       protected static final String unreserved = "[a-zA-Z0-9\\-\\._~]";
+       //  pct-encoded   = "%" HEXDIG HEXDIG
+       protected static final String pctEncoded = "%[0-9A-Fa-f][0-9A-Fa-f]";
+       //  sub-delims    = "!" / "$" / "&" / "'" / "(" / ")"
+       //                / "*" / "+" / "," / ";" / "="
+       protected static final String subDelims  = "[\\!\\$&'\\(\\)\\*\\+,;=]";
+       //  pchar         = unreserved / pct-encoded / sub-delims / ":" / "@"
+       protected static final String pchar      = "(" + unreserved + "|" + 
pctEncoded + "|" + subDelims + "|[:@])";
+       //  fragment      = *( pchar / "/" / "?" )
+       protected static final String fragment   = "(" + pchar + "|\\/|\\?)*";
+
        public String processURI(String u, String overrideType, boolean 
noRelative, boolean inline) throws CommentException {
-               if(u.matches("^#[a-zA-Z0-9-_]+$")) {
+               if(u.matches("^#" + fragment + "$")) {
                        // Hack for anchors, see #710
                        return u;
                }

_______________________________________________
cvs mailing list
[email protected]
http://emu.freenetproject.org/cgi-bin/mailman/listinfo/cvs

Reply via email to