You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Sebb (JIRA)" <ji...@apache.org> on 2014/02/20 12:56:21 UTC
[jira] [Comment Edited] (NET-516) problem occurs if the filename
contains one or more characters of which the second byte of Shift-JIS code
is 0x85
[ https://issues.apache.org/jira/browse/NET-516?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13906796#comment-13906796 ]
Sebb edited comment on NET-516 at 2/20/14 11:55 AM:
----------------------------------------------------
The issue is happening because of the regular expression used from commons-net-2.0. The regex used by the commons-net 2.0 is
{noformat}
(\\S+)\\s+(\\S+)\\s+(?:(<DIR>)|([0-9]+))\\s+(\\S.*)
{noformat}
If you carefully look at the last capturing group
{noformat}
(\\S.*)
{noformat}
first it looks for a non whitespace character then for any character.
According the java pattern class documentation 0x85 is a line terminator and also .* by default only matches printable characters and wont match any control characters. Creating the pattern using Pattern.DOTALL makes control characters also to match. I am attaching a sample program for reproducing the issue.
was (Author: sunnykumar):
The issue is happening because of the regular expression used from commons-net-2.0. The regex used by the commons-net 2.0 is (\\S+)\\s+(\\S+)\\s+(?:(<DIR>)|([0-9]+))\\s+(\\S.*). If you carefully look at the last capturing group (\\S.*) first it looks for a non whitespace character then for any character.
According the java pattern class documentation 0x85 is a line terminator and also .* by default only matches printable characters and wont match any control characters. Creating the pattern using Pattern.DOTALL makes control characters also to match. I am attaching a sample program for reproducing the issue.
> problem occurs if the filename contains one or more characters of which the second byte of Shift-JIS code is 0x85
> ------------------------------------------------------------------------------------------------------------------
>
> Key: NET-516
> URL: https://issues.apache.org/jira/browse/NET-516
> Project: Commons Net
> Issue Type: Bug
> Components: FTP
> Affects Versions: 2.0
> Environment: windows
> Reporter: Asha K S
> Fix For: 2.0
>
> Attachments: FTPSample.java, notworking.png, working.png
>
>
> Problem occurs if the filename contains one or more characters of which the second byte of Shift-JIS code is 0x85, on a windows Japanese machine when listing file names from IIS FTP server.
> This was working fine in commons-net-1.4.0.jar .
--
This message was sent by Atlassian JIRA
(v6.1.5#6160)