External storage doesnt work properly with file/dir attributes on Windows/samba share

I faced strange behavior with external (SMB) storage.

My setup:
Nextcloud 20.0.12 (docker container, with smbclient installed)
Ubuntu server 18.04
Windows Server 2019 (there is SMB shared storage)

I have several SMB shares mounted to Nexcloud server without problem but folders or files that have the “I” attribute set ( ie Not content indexed file attribute) are displayed in the web interface as follows:

nextcloud-bug-1

Original directory attribute (“Dn” or “An”) is a part of directory / filename. The attribute is also part of the destination URL, like this:

../TEST%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Dn

so when I try to open a folder or file I get an Internal error. As soon as I remove the attribute “I” of the folder in question, the folder is immediately accessible again.

If I try to open shared folders directly using smbclient, the names and attributes of the files are displayed correctly and the folders can be browsed normally:

smb: \> ls
  .                                   D        0  Sat Sep 25 20:37:14 2021
  .. 
  TEST                               Dn        0  Sat Sep 25 15:28:51 2021
  TEST with I attribute.txt          An        0  Sat Sep 25 20:34:13 2021
  TEST without I attribute.txt        A        0  Sat Sep 25 20:34:44 2021

You can see “Dn” and “An” attributes in its columns.
There is no error logged in Netxloud log, no error logged on Windows server of course.

It seems to be not an error in communication between smbclient and Windows server, but a bug in the interpretation of file attributes by External Storage Support applications.

(Note: “I” attribute is represented as “N” in smbclient.)