miketeo/pysmb

Fail to create file with "unicode filename" SMB2

Closed this issue · 5 comments

Issue discription:
I try to upload a pdf named "ä.pdf" with the storeFileFromOffset function to a SMB2 Folder.
In generell any non-ascii will have this problem.

OS:
Client: Linux
Server: Windows Server

I get no error message in log but the file will never show up in the folder.

So i created some network captures but still can't figure out why the file will not be created.

fail1

fail2

With SMB1 everythings works fine, to ensure encoding i had to encode the filename with self.filename.encode('utf-8', 'surrogateescape').decode('utf-8') in smb_structs aswell in smb2_structs.

If you need any further information or testing please contact.

Regards,
Fabian

Have you tried passing in the filename to the storeFileFromOffset function like this: u"ä.pdf" ?

Thanks for the hint, i will try it on thursday.

using u"filename" was not working for me so i added encoding utf-8 with surrogateescape

If you like to check:
Fabian1337@0b19e01

Could be an encoding problem in the python script file.
Maybe you want to look at PEP 263 to see how to specify encoding for the python file. The specified encoding header should match the encoding used for your code editor.

its working with my work around so i will close this issue. thanks for your fast response.