Fix FtpAdapter listing parser swallowing entries whose name ends in ":"#1899
Open
tomsommer wants to merge 1 commit into
Open
Fix FtpAdapter listing parser swallowing entries whose name ends in ":"#1899tomsommer wants to merge 1 commit into
tomsommer wants to merge 1 commit into
Conversation
The section-header regex `^.*:$` in FtpAdapter::normalizeListing() was
intended to catch recursive-listing headers like `./subdir:` from
`ls -lR`, but also matches a regular `ls -l` row whose filename ends
in `:` — e.g. a directory literally named `C:`:
drwxr-xr-x 2 1000 1000 4096 May 19 07:32 C:
The entry is mistaken for a header, silently dropped, and $base is
set to the raw `ls -l` text. Every subsequent item in the same
listing then yields with a garbage prefix.
Real recursive-listing section headers never contain whitespace, so
restrict the regex to `^\S+:$`. Existing recursive-listing behaviour
is unchanged; directories whose names end in `:` now round-trip.
Adds a parser test alongside the existing receiving_a_unix_listing
test using the same mock_function('ftp_rawlist', ...) pattern.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
FtpAdapter::normalizeListing()treats any listing line ending in:as a recursive-listing section header (./subdir:fromls -lR). The regex^.*:$also matches a regularls -lrow whose filename happens to end in:— e.g. a directory literally namedC::The line is mistaken for a header, the entry is silently dropped, and
\$baseis set to the entire rawls -ltext. Every subsequent item in the same listing then yields with a garbage prefix like:Following one of those paths back into
listContents()either returns an empty list or throwsInvalidListResponseReceivedfrom the next parse.Fix
Tighten the regex to
^\S+:$. Real recursive-listing section headers never contain whitespace (./somedir:,./somedir/subdir:,.:); regularls -lrows always do. Existing recursive-listing behaviour is unchanged; directories whose names end in:now round-trip correctly.Reproducer
Test
Added a parser test in
FtpAdapterTestCasealongside the existingreceiving_a_unix_listingtest, using the samemock_function('ftp_rawlist', ...)pattern.