Skip to content

Directory listing encoding problem #78

@wakproductions

Description

@wakproductions

I'm trying to get a directory listing from an SFTP server and I'm getting this output:

pry(#<Net::SFTP::Session>)> request.response[:names]
=> [#<Net::SFTP::Protocol::V04::Name:0x00007fae6c141a00
  @attributes=
   #<Net::SFTP::Protocol::V04::Attributes:0x00007fae6c141a50
    @attributes={:type=>2, :size=>0, :owner=>"root", :group=>"root", :permissions=>16895, :atime=>1534766503, :createtime=>1534766503, :mtime=>1534766503}>,
  @name=".">,
 #<Net::SFTP::Protocol::V04::Name:0x00007fae6c140fb0 @attributes=#<Net::SFTP::Protocol::V04::Attributes:0x00007fae6c1410c8 @attributes={:type=>2}>, @name="\x00\x00\x00\x02">,
 #<Net::SFTP::Protocol::V04::Name:0x00007fae6c140560
  @attributes=#<Net::SFTP::Protocol::V04::Attributes:0x00007fae6c1406a0 @attributes={:type=>1}>,
  @name=
   "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04root\x00\x00\x00\x04root\x00\x00A\xFF\x00\x00\x00\x00[ \xE6\x89\x00\x00\x00\x00[\"\\F\x00\x00\x00\x00[ \xE6\x89\x00\x00\x00\x04\x00\x00\x00!2018-08-17-15-32-TAFUS-GIDREQ.xml\x00\x00\x02\xBD\x01\x00\x00\x00\x00\x00\x1D\xCF\x15\x00\x00\x00\x04root\x00\x00\x00\x04root\x00\x00\x81\xFF\x00\x00\x00\x00[z\xAD\xF5\x00\x00\x00\x00[z\xAD\xF5\x00\x00\x00\x00[z\xAD\xF5\x00\x00\x00\x00\x00\x00\x00!2018-08-21-17-30-TAFUS-GIDREQ.xml\x00\x00\x02\xBD\x01\x00\x00\x00\x00\x00\x05\xB4p\x00\x00\x00\x04root\x00\x00\x00\x04root\x00\x00\x81\xFF\x00\x00\x00\x00[|L\xA5\x00\x00\x00\x00[|L\xA5\x00\x00\x00\x00[|L\xA5\x00\x00\x00\x00">,
 #<Net::SFTP::Protocol::V04::Name:0x00007fae6c140150 @attributes=#<Net::SFTP::Protocol::V04::Attributes:0x00007fae6c1401a0 @attributes={:type=>1}>, @name=nil>]

The filenames are scrambled with \x00 type of characters. It looks like an encoding issue, but I'm having trouble figuring out how to do a proper conversion. Can anyone help lead me into the right direction to working around this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions