[ 
https://issues.apache.org/jira/browse/NET-745?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18098033#comment-18098033
 ] 

Sarankumar Baskar commented on NET-745:
---------------------------------------

[~ggregory]  After reproducing this locally, I confirmed:

- OS400FTPEntryParser does not match the reported listings at all (returns 
null). The entries are Unix-style, not native OS/400.
- UnixFTPEntryParser matches the entries. With trimLeadingSpaces=false (the 
default), previous-year entries produce a filename with a leading space.
- With trimLeadingSpaces=true, the filename is parsed correctly.

The single-space separator in the regex is intentional — Unix filenames can 
legitimately start with spaces, so the parser preserves them by default. The 
trimLeadingSpaces option (added in 3.4) exists for this case.

[~msepryor] likely needs to configure the parser with trimLeadingSpaces=true, 
or the auto-detection logic may need to default trimLeadingSpaces differently 
for OS/400 systems returning Unix-style listings.

> OS400FTPEntryParser returns filename with leading space when listing contains 
> a year instead of time
> ----------------------------------------------------------------------------------------------------
>
>                 Key: NET-745
>                 URL: https://issues.apache.org/jira/browse/NET-745
>             Project: Commons Net
>          Issue Type: Bug
>            Reporter: Sarankumar Baskar
>            Priority: Major
>
> OS400FTPEntryParser produces a filename with a leading space when the FTP 
> directory listing contains a year (previous-year entries) instead of a time 
> (current-year entries).
> In standard Unix-style directory listings, the date/time column is 
> fixed-width. When the listing shows a year like "2025" instead of a time like 
> "15:46", the output is padded with an extra space to maintain column 
> alignment. The parser's regex captures that extra space as part of the 
> filename.
> Reproduction:
> Current-year entry (parsed correctly):
>   Raw:  "-rwxrwxrwx   1 TLXDRIVER 0        1592686 Jul 14 15:46 cloudfax.jar"
>   Name: "cloudfax.jar"
> Previous-year entry (leading space in name):
>   Raw:  "-rwxrwxrwx   1 TLXDRIVER 0        27432520 Apr 24  2025  
> itextpdf-5.2.1.jar"
>   Name: " itextpdf-5.2.1.jar"
> Expected: FTPFile.getName() should return "itextpdf-5.2.1.jar" without a 
> leading space.
> Suggested fix: adjust the regex in OS400FTPEntryParser to allow one or more 
> whitespace characters before the filename capture group, or trim the captured 
> filename.
> Reported on dev mailing list by Matt Pryor.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to