HostFileNameParser fails extracting user info
---------------------------------------------
Key: VFS-88
URL: http://issues.apache.org/jira/browse/VFS-88
Project: Commons VFS
Issue Type: Bug
Environment: any
Reporter: Vincentas Vienozinskis
Priority: Trivial
class org.apache.commons.vfs.provider.HostFileNameParser fails to extract user
infomation from uri such as :
ftp://[EMAIL PROTECTED]:[EMAIL PROTECTED]
Note that
User name : [EMAIL PROTECTED]
Password : userpassword
As above uri is valid it should be parsed without exceptions. To fix this first
':' should be found instead of looking for '@' sign:
fixed method :
/**
* Extracts the user info from a URI. The scheme:// part has been removed
* already.
*/
protected String extractUserInfo(final StringBuffer name)
{
final int maxlen = name.length();
// First look for user info separator ':' then for '@'
boolean separatorFound = false;
for (int pos = 0; pos < maxlen; pos++)
{
final char ch = name.charAt(pos);
if (ch == ':') {
separatorFound = true;
}
if (ch == '@' && separatorFound)
{
// Found the end of the user info
String userInfo = name.substring(0, pos);
name.delete(0, pos + 1);
return userInfo;
}
if (ch == '/' || ch == '?')
{
// Not allowed in user info
break;
}
}
// Not found
return null;
}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]