Dear all,

Here is a patch I wrote for Aelfred2. I post it to this list because I
understand that Aelfred2 development is now done by the Classpath
project, please correct me if I am wrong.

My patch adds URI scheme name validation to the SAXDriver, as a FIXME
in the source code was asking for.

Keep up the good work,
Nicolas Raoul.
http://nrw.free.fr

Patch for revision 1.1.2.7 of
/classpath/classpath/gnu/xml/aelfred2/SAXDriver.java :

867,868c867,877
<     // FIXME:  char [0] must be ascii alpha; chars [1..index]
<     // must be ascii alphanumeric or in "+-." [RFC 2396]
---
>     // char [0] must be ascii alpha [RFC 2396]
>     if( ! isAlpha(uri.charAt(0))) {
>       fatal("First character of the URI must be ascii alpha");
>     }
>       
>     // chars [1..index] must be ascii alphanumeric or in "+-." [RFC 2396]
>     for(int i=1; i<index; i++) {
>       if( ! isAlphanumericOrPlusMinusPoint(uri.charAt(i))) {
>       fatal("Character " + i + " of the URI must be ascii alpha or in 
> \"+-.\"");
>       }
>     }
1168a1178,1210
>   /**
>    * Checks whether a given character is an ASCII alpha or not.
>    * @param character
>    *                  The character to check.
>    * @return
>    *                  True if the character is an ASCII alpha.
>    */
>   private boolean isAlpha(char character)
>   {
>     // Range of alpha characters in ASCII, should be the same for
>     // Unicode according to "The Unicode Standard 4.0", section 5.2
>     return (character >= 'A' && character <='Z' ) // Unicode A..Z
>       || (character >= 'a' && character <= 'z'); // Unicode a..z
>   }
>
>   /**
>    * Checks whether a given character is in "+-." or an ASCII alphanumeric.
>    * This is useful for a check related to [RFC 2396]
>    * @param character
>    *                  The character to check.
>    * @return
>    *                  True if the character is in "+-." or an ASCII 
> alphanumeric.
>    */
>   private boolean isAlphanumericOrPlusMinusPoint(char character)
>   {
>     return (character >= 'A' && character <= 'Z') // Unicode A..Z
>       || (character >= 'a' && character <= 'z') // Unicode a..z
>       || (character >= '0' && character <= '9') // Unicode 0..9
>       || character == '+'
>       || character == '-'
>       || character == '.';
>   }
>

Reply via email to