Bug 400567 - Choosing mail signature from a file deletes the selected file causing data loss
Summary: Choosing mail signature from a file deletes the selected file causing data loss
Status: RESOLVED FIXED
Alias: None
Product: kmail2
Classification: Applications
Component: config dialog (show other bugs)
Version: 5.21.3
Platform: openSUSE Linux
: NOR major
Target Milestone: ---
Assignee: kdepim bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-11-01 22:25 UTC by Chris H
Modified: 2023-02-04 07:13 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
curious dialog (13.79 KB, image/png)
2018-11-02 07:12 UTC, Christophe Marin
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Chris H 2018-11-01 22:25:47 UTC
SUMMARY
Data loss / file deletion when attempting to set a signature from pre-existing file for (default?) identity.

STEPS TO REPRODUCE
1. Settings > Configure KMail
2. Accounts > Identities > Modify...
3. Edit Identity > Signatures > Enable signature is ticked
4. Obtain from: File
5. Select a file.
6. Now here I can't remember whether I hit OK, Cancel or Edit file

OBSERVED RESULT
Data loss, the file is deleted.

Some output from terminal:
QFSFileEngine::open: No file name specified
org.kde.pim.kidentitymanagement: Failed to open "" : "No file name specified"
command= "kwrite %U" args= ("kwrite %U", "file:///home/chris/sigs/CallMeLess")
EXEC  "/usr/bin/kwrite /home/chris/sigs/CallMeLess"
EXEC done
sleeping...
org.kde.pim.messagecore: Serious mailing list header parsing error!
org.kde.pim.messagecore: Serious mailing list header parsing error!
qt.qpa.xcb: QXcbConnection: XCB error: 8 (BadMatch), sequence: 15797, resource id: 117440574, major code: 130 (Unknown), minor code: 3
qt.qpa.xcb: QXcbConnection: XCB error: 8 (BadMatch), sequence: 15800, resource id: 117440574, major code: 130 (Unknown), minor code: 3
qt.qpa.xcb: QXcbConnection: XCB error: 8 (BadMatch), sequence: 15803, resource id: 117440574, major code: 130 (Unknown), minor code: 3
about to delete "/home/chris/sigs" containing "CallMeLess"




EXPECTED RESULT
File is not deleted. File gets added to the bottom of new messages using that identity.

SOFTWARE VERSIONS
(available in About System)
KDE Plasma Version: 5.14.2
KDE Frameworks Version: 4.51.0
Qt Version: 5.11.2

ADDITIONAL INFORMATION
Comment 1 Laurent Montel 2018-11-02 06:11:49 UTC
I don't understand your bug.
So which file do you select ?
Do you select a real file ?
if not what do you lose ?

Regards
Comment 2 Christophe Marin 2018-11-02 07:12:54 UTC
Created attachment 116040 [details]
curious dialog

Maybe the report is about that.

I'm getting this after selecting a file, pressing edit, modify, save an close the text editor
Comment 3 Laurent Montel 2018-11-02 08:13:59 UTC
(In reply to Christophe Giboudeaux from comment #2)
> Created attachment 116040 [details]
> curious dialog
> 
> Maybe the report is about that.
> 
> I'm getting this after selecting a file, pressing edit, modify, save an
> close the text editor

I can't show this error.
What is your editor ?
(here it's kate)
Comment 4 Christophe Marin 2018-11-02 08:21:22 UTC
kwrite is used here
Comment 5 Christophe Marin 2018-11-02 08:25:19 UTC
nothing special in the KMail output:
9:22:21 - kioexec(24820) -  KIOExec::KIOExec: command= "kwrite %U" args= ("kwrite %U", "file:///home/krop/testsig2.txt")
[ksycoca stuff]
9:22:21 - kioexec(24820) -  KIOExec::slotRunApp: EXEC  "/data/kde/inst/bin/kwrite /home/krop/testsig2.txt"

After closing the editor:

9:23:47 - kioexec(24820) -  KIOExec::slotRunApp: EXEC done
Comment 6 Chris H 2018-11-02 09:55:38 UTC
(In reply to Laurent Montel from comment #1)
> I don't understand your bug.
> So which file do you select ?
> Do you select a real file ?
> if not what do you lose ?
> 
> Regards

I selected a short text file that I had in the folder.
It is a real file, simple text format.
That file is deleted.
Comment 7 Chris H 2018-11-02 10:00:09 UTC
(In reply to Christophe Giboudeaux from comment #2)
> Created attachment 116040 [details]
> curious dialog
> 
> Maybe the report is about that.
> 
> I'm getting this after selecting a file, pressing edit, modify, save an
> close the text editor

I didn't see that dialogue, so I believe it is unrelated to the issue I've reported. (At least in terms of steps I took)
Comment 8 Allen Winter 2018-11-02 15:34:23 UTC
I played with this a little , and while I couldn't cause the file to be deleted, I was able to find some things that can be improved:

1) the openfile dialog should filter on .txt files.  so people like me don't mistakenly use huge .pdf files :)
2) limit the signature to at most 10? lines so huge files don't cause new composer slowness
Comment 9 Laurent Montel 2018-11-02 17:31:27 UTC
(In reply to Allen Winter from comment #8)
> I played with this a little , and while I couldn't cause the file to be
> deleted, I was able to find some things that can be improved:
> 
> 1) the openfile dialog should filter on .txt files.  so people like me don't
> mistakenly use huge .pdf files :)

I fixed it this morning (master only)

> 2) limit the signature to at most 10? lines so huge files don't cause new
> composer slowness

It seems to be a good idea to make a limitation.
I will investigate it.
Comment 10 Christophe Marin 2018-11-03 21:13:43 UTC
(In reply to Allen Winter from comment #8)

> 2) limit the signature to at most 10? lines so huge files don't cause new
> composer slowness

I don't recommend changing this, some companies *love* lengthy signatures
Comment 11 Laurent Montel 2018-11-05 06:58:40 UTC
(In reply to Christophe Giboudeaux from comment #10)
> (In reply to Allen Winter from comment #8)
> 
> > 2) limit the signature to at most 10? lines so huge files don't cause new
> > composer slowness
> 
> I don't recommend changing this, some companies *love* lengthy signatures

I added just a warning about big text.
I don't limit it.
Comment 12 BingMyBong 2022-12-01 11:44:05 UTC
Using kmail2 version 5.21.3
 
SUMMARY
***
I auto-generate my email signature file on login (see lines above) so its up to 
date.
I went to the configure signature stab and the "Specify File" box has my file 
name there correctly.  I pressed "Edit File"  and it loaded "kate" and my file 
quite happily. 
I then closed "kate" without editing the file in any way and the file is deleted 
from my file system.
I get the same result of a deleted file even if i edit the file and save it in the "kate Edit File" session
***

STEPS TO REPRODUCE
1.  Select Identity in Accounts/Identities box
2.  Click <Modify> 
3.  Select Signature tab
4.  Click <Edit File> next to signature file to edit my signature file (3 lines long)
5.  Either edit file and save in Kate or just exit without any actions.
6. The signature file should still exist after exit from kate

OBSERVED RESULT
Signature file deleted after exiting kate even if saved within kate

EXPECTED RESULT
Signature file should still exist with any modifications made after exiting kate

SOFTWARE/OS VERSIONS
opensuse:tumbleweed:20221129
Qt: 5.15.7 KDE Frameworks: 5.100.0 - KDE Plasma:  5.26.3 - kwin 5.26.3
kmail2 5.21.3 (22.08.3) - - Kernel:  6.0.8-1-default  - kernel-firmware-radeon  20221109

ADDITIONAL INFORMATION - running from cli
kmail
Running on wayland. Qt WebEngine will disable usage of the GPU.
Note: you can set the QT_WEBENGINE_DISABLE_WAYLAND_WORKAROUND
environment variable before running this application, but this is 
not recommended since this usually causes applications to crash.
qt.qpa.wayland: Wayland does not support QWindow::requestActivate()
QWidget::setLayout: Attempting to set QLayout "" on QGroupBox "", which already has a layout
qt.qpa.wayland: Wayland does not support QWindow::requestActivate()
kf.kio.widgets.kdirmodel: No node found for item that was just removed: QUrl("file:///home/seeker/.RELEASE_LEVELS.kate-swp")
Comment 13 Jonathan Marten 2023-02-03 15:21:09 UTC
Coinfirmed with current Git master.

This happens because SignatureConfigurator::slotEdit() calls job->setDeleteTemporaryFile(true).  This should not be done, it is telling the job that the file specified is a temporary file and therefore should be deleted (after a delay of 3 minutes) when the editor is closed.  If the file URL is remote, KIO will handle downloading it to a temporary file and deleting the local copy afterwards itself.
Comment 14 Bug Janitor Service 2023-02-03 15:35:34 UTC
A possibly relevant merge request was started @ https://invent.kde.org/pim/kidentitymanagement/-/merge_requests/18
Comment 15 Jonathan Marten 2023-02-03 22:25:22 UTC
Git commit 9150359070370ae43897c01e94cb0a523676c2d2 by Jonathan Marten.
Committed on 03/02/2023 at 15:31.
Pushed by mlaurent into branch 'master'.

Signature editor: Do not specify that the edit file is temporary

Specifying this explicitly means that the user's signature file will
be deleted (after a delay) after editing it.  Let KIO handle the
decision itself.

M  +0    -1    src/widgets/signatureconfigurator.cpp

https://invent.kde.org/pim/kidentitymanagement/commit/9150359070370ae43897c01e94cb0a523676c2d2
Comment 16 Laurent Montel 2023-02-04 07:13:50 UTC
Git commit dc2a9a84c5dd65579555b794b8409257784b5119 by Laurent Montel, on behalf of Jonathan Marten.
Committed on 04/02/2023 at 07:13.
Pushed by mlaurent into branch 'release/22.12'.

Signature editor: Do not specify that the edit file is temporary

Specifying this explicitly means that the user's signature file will
be deleted (after a delay) after editing it.  Let KIO handle the
decision itself.
(cherry picked from commit 9150359070370ae43897c01e94cb0a523676c2d2)

M  +0    -1    src/widgets/signatureconfigurator.cpp

https://invent.kde.org/pim/kidentitymanagement/commit/dc2a9a84c5dd65579555b794b8409257784b5119