Parse file with a # in the path
-------------------------------

                 Key: XERCESJ-1319
                 URL: https://issues.apache.org/jira/browse/XERCESJ-1319
             Project: Xerces2-J
          Issue Type: Improvement
          Components: SAX
    Affects Versions: 2.9.1
            Reporter: Julien Maria
            Priority: Trivial


Hello,
When I tri to parse a File with the char # in the filename or in the path, I 
have the exception java.io.FileNotFoundException

Regards
Julien

The change should be very minor, something like this : 
public class XMLEntityManager
    implements XMLComponent, XMLEntityResolver {
......
    protected static String fixURI(String str) {
....
         int pos = str.indexOf(' ');
        int pos2 = str.indexOf('#');
        pos = pos < pos2 ? pos : pos2;
        // there is no space or # in the string
        // we just append "str" to the end of sb
        if (pos < 0) {
            if (sb != null) {
                sb.append(str);
                str = sb.toString();
            }
        }
        // otherwise, convert all ' ' to "%20" and all '#' to "%23".
        // Note: the following algorithm might not be very performant,
        // but people who want to use invalid URI's have to pay the price.
        else {
            if (sb == null)
                sb = new StringBuffer(str.length());
            // put characters before ' ' into the string buffer
            for (int i = 0; i < pos; i++)
                sb.append(str.charAt(i));
            // for the remamining part, also convert ' ' to "%20".
            for (int i = pos; i < str.length(); i++) {
                if (str.charAt(i) == ' ')
                    sb.append("%20");
                else if (str.charAt(i) == '#')
                    sb.append("%23");
                else
                    sb.append(str.charAt(i));
            }
            str = sb.toString();
        }

        // done
        return str;

    } // fixURI(String):String

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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

Reply via email to