You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by "Michael Glavassevich (JIRA)" <xe...@xml.apache.org> on 2008/11/23 17:01:44 UTC
[jira] Resolved: (XERCESJ-1319) Parse file with a # in the path
[ https://issues.apache.org/jira/browse/XERCESJ-1319?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Michael Glavassevich resolved XERCESJ-1319.
-------------------------------------------
Resolution: Invalid
Sorry we cannot do this. The '#' character has special meaning in a URI. It is the delimeter for the fragment identifier (see section 4.1 here [1]). If '#' is part of a file's path it is the user's responsibility to escape it. Xerces cannot blindly replace it. There's no way it could tell the difference between a '#' in the path or as the separator for the fragment identifier.
[1] http://www.ietf.org/rfc/rfc2396.txt
> 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 try to parse a File with the char # in the filename or in the path, I have the exception java.io.FileNotFoundException
> 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
> Regards
> Julien
--
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: j-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-dev-help@xerces.apache.org