You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Jean Pierre Urkens (JIRA)" <ji...@apache.org> on 2018/12/20 08:52:00 UTC
[jira] [Commented] (VFS-524) The uri include ipv6 address can't be
parsed out correctly
[ https://issues.apache.org/jira/browse/VFS-524?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16725672#comment-16725672 ]
Jean Pierre Urkens commented on VFS-524:
-----------------------------------------
I am trying to setup an FTP connection to the IPv6 loopback address using commons-vfs2 version 2.2 and commons-net v3.6.
I tried following URI'S: [ftp://[::1]|ftp://[:1]] and [ftp://[0:0:0:0:0:0:0:1]|ftp://[::1]/] but I am allways getting the error:
org.apache.commons.vfs2.FileSystemException: Invalid absolute URI "[ftp://[0:0:0:0:0:0:0:1]|ftp://[::1]/]
Isn't the fix present in v2.2 or am I missing something here?
> The uri include ipv6 address can't be parsed out correctly
> ----------------------------------------------------------
>
> Key: VFS-524
> URL: https://issues.apache.org/jira/browse/VFS-524
> Project: Commons VFS
> Issue Type: Bug
> Affects Versions: 2.0
> Reporter: Alex
> Priority: Major
> Attachments: VFS-524-v2.patch, VFS-524-v3.patch
>
>
> I am using apache commons vfs2 to read and download file in ipv6 enviroment, but it seems can't parse out ipv6 address correctly
> The URI is just like:
> ftp://[2002:9ba:b4e:6:a052:5792:c0c9:2330]/test
> The error message:
> Invalid absolute URI "ftp://[2002:9ba:b4e:6:a052:5792:c0c9:2330]/test".
> Caused by : Expecting / to follow the hostname in URI "ftp://[2002:9ba:b4e:6:a052:5792:c0c9:2330]/test".
> Deep into the code, I found the root cause is that HostFileNameParser's extractHostName can't parse out the host name correctly
> {noformat}
> /**
> * Extracts the hostname from a URI. The scheme://userinfo@ part has
> * been removed.
> */
> protected String extractHostName(final StringBuilder name)
> {
> final int maxlen = name.length();
> int pos = 0;
> for (; pos < maxlen; pos++)
> {
> final char ch = name.charAt(pos);
> if (ch == '/' || ch == ';' || ch == '?' || ch == ':'
> || ch == '@' || ch == '&' || ch == '=' || ch == '+'
> || ch == '$' || ch == ',')
> {
> break;
> }
> }
> if (pos == 0)
> {
> return null;
> }
> final String hostname = name.substring(0, pos);
> name.delete(0, pos);
> return hostname;
> }
> {noformat}
> From the code, we are able to know it will parse out the host name by colon, but for ipv6, it will get a wrong host name
> There is the same problem with the other protocol like sftp and cifs
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)