Closed Bug 1598865 Opened 5 years ago Closed 5 years ago

Thunderbird loads System File as Mail Folder

Categories

(MailNews Core :: Database, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
Thunderbird 73.0

People

(Reporter: lars.andersen, Assigned: aceman)

Details

Attachments

(1 file, 1 obsolete file)

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.99 Safari/537.36 Vivaldi/2.9.1705.41

Steps to reproduce:

My Thunderbird "Local Folders" are pointing to C:\Users\Lars\Emails\Local Folders
Then I add an Icon to this folder (Right Click, Properties, Customize, Change Icon)
The new icon gets stored in C:\Users\Lars\Emails\Local Folders\desktop.ini
Desktop.ini is a new Hidden System File containing the link to the new icon

Actual results:

When opening Thunderbird, under "Local Folders", a new folder called "desktop.ini" appears (and the system also adds a folder called "desktop.ini.msf" to the C:\Users\Lars\Emails\Local Folders directory.
Naturally this "desktop.ini" folder is empty.

Expected results:

Thunderbird should never load a System File (whether hidden or not) as a mail folder but should only load User Files.

Tested also v.71.0b3 (64 Bits) - same issue

I don't know that we would fix this. System file or not, you caused it to be created and are touching a structure that belongs Thunderbird. By design TB displays any file in these directories that it does next expect as a mail folder

OK - each file in a directory has Attributes e.g. is the file a system file, a hidden file etc. so when issuing the command to read a directory, it must be possible to exclude system files all together.

I don't know which command you use to retrieve the content of a directory for processing. If it is the DIR command, then it's easy to exclude system files using the attribute parameter. The Unix equivalent "LS" has similar functionality - as the system files are clearly "Tagged".

Windows could add other system files to a directory such as thumbs.db - these system files are only partially under user control.

When Thunderbird decides to open one of the system files, and if I move a message to that file, then the system file will be corrupted and Windows won't know what to do with it - that the fundamental issue.

It's not just happening with the "Local Folders" directory, it also happens in individual Mail Account Directories - when a system file is present.

Don't know if this should be an "Enhancement", I logged it as a bug due to the risk of system file corruption with the current behaviour.

Assume Thunderbird is Java based - just wanted to ad a couple of classes which allows to find both the "Hidden" and the "System" attribute.

http://www.java2s.com/Tutorials/Java/Java_io/1000__Java_nio_File_Attributes.h
https://docs.oracle.com/javase/8/docs/api/java/nio/file/attribute/DosFileAttributeView.html

As stated before, my personal opinion is, that Thunderbird should not touch a file if it is hidden or if it is a system file ......

Hope for a positive answer to this request

all the best,
Lars

I think this sounds useful.
We already have infrastructure to ignore some files in the filesystem folders and not turn them into mail folders, for some internal TB files.

It is true that Windows creates hidden files in folders, like for the thumbnails, and apparently the desktop.ini file.

This would need some platform specific code to determine what is a hidden or system file on each platform. Windows does use the file attributes. On Linux e.g. dot named files are considered hidden or special device type files could be ignored. The same could be on OS X.

Lars, this code in Thunderbird is in C++, not Java. Do you have some sample code for getting the file attributes in Windows?

Status: UNCONFIRMED → NEW
Type: defect → enhancement
Component: Folder and Message Lists → Database
Ever confirmed: true
OS: Unspecified → All
Product: Thunderbird → MailNews Core
Hardware: Unspecified → All

Aceman, can probably use file.isHidden: https://searchfox.org/comm-central/source/mozilla/xpcom/io/nsIFile.idl#276

Lars: no Java in Thunderbird. It's JavaScript, C++ and some Rust.

Thanks, and also nsIFile.isSpecial seems to cover the system files on Windows and device files on Linux.
In that case I can do something here.

Assignee: nobody → acelists
Attached patch 1598865.patch (obsolete) — Splinter Review

I have tested this on Linux where the patch successfully ignored a block device file. Hidden files (starting with a dot) were already ignored by an explicit check for 'temporary' files in nsMsgLocalStoreUtils::nsShouldIgnoreFile (visible in the patch).

It could use some testing on Windows and OS X by dropping some hidden or system files into the profile/Mail/server folder.

The directoryEnumerator shuffling in ImapFolder is to make that logic more similar to the same loops in nsMsgBrk*Store, but also to fix a theoretical bug when after fetching the last directory entry we checked children->HasMoreElements(&more) again and if that would fail, we wouldn't process the last dir entry (currentFolderPath) but exit.

Try run:
https://treeherder.mozilla.org/#/jobs?repo=try-comm-central&selectedJob=278902082&revision=dd549308dc1e6f59684f6c989296d8254c16e0a0

Attachment #9112718 - Flags: review?(mkmelin+mozilla)
Attachment #9112718 - Flags: feedback?(richard.marti)
Status: NEW → ASSIGNED
Comment on attachment 9112718 [details] [diff] [review]
1598865.patch

This works on Windows. On macOS hidden files (the ones with leading dot) are already hidden like on Linux. I don't know how to copy a block device into the folder under macOS but I think it's similar to Linux and would also hide them like on Linux.
Attachment #9112718 - Flags: feedback?(richard.marti) → feedback+

Thanks. Adding a comment to the new check block.

Attachment #9112718 - Attachment is obsolete: true
Attachment #9112718 - Flags: review?(mkmelin+mozilla)
Attachment #9112765 - Flags: review?(mkmelin+mozilla)
Attachment #9112765 - Attachment is patch: true
Comment on attachment 9112765 [details] [diff] [review]
1598865.patch v1.1

Review of attachment 9112765 [details] [diff] [review]:
-----------------------------------------------------------------

Thx! r=mkmelin
Attachment #9112765 - Flags: review?(mkmelin+mozilla) → review+

Thanks.

Pushed by mkmelin@iki.fi:
https://hg.mozilla.org/comm-central/rev/375496910e92
do not use new hidden/system files detected in mail account local storage as mail folders. r=mkmelin

Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → Thunderbird 73.0
Type: enhancement → defect

Good work. And thanks for suggesting this.

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: