New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SFTP::nlist returns integer entries for files names consisting of digits only #1623
Comments
SFTP::nlist
returns integer entries for files names consisting of digits only
After a quick glance into the code, this might be related to the entries being stored as array keys in the |
Interesting. https://stackoverflow.com/a/35180513/569976 suggests that there is kinda a workaround for it but an imperfect one. I suppose the parameter to As for fixing this going forward... #1418 would do the trick. It wouldn't be an array - it'd be an object that looked like an array. But that's a BC breaking change that wouldn't be included in 1.0 / 2.0 / 3.0. |
Are you concerned about changing the return value of phpseclib/phpseclib/Net/SFTP.php Line 983 in f2733c5
might do the trick, as far as I can see; so casting the list to strings explicitly before returning. In the other case, the behavior is not surprising at least in the case that you are aware of PHP implicitly casting array keys to |
No. getting Anyway, your proposed solution seems reasonable. I'll try to implement it in the next few days! |
The proposed code change is now live!: Thanks! |
If I run
$sftp->nlist()
in a directory with a file (or directory) named20210228
, I get the following result fromvar_dump
:Shouldn't the file names always be
string
? The integer entries will result in warnings if I try something like this:phpseclib version 2.0.30
Tested on PHP 7.4.15 and 8.0.2
The text was updated successfully, but these errors were encountered: