After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 695107 - When document contains invalid characters, Save As is results in Save
When document contains invalid characters, Save As is results in Save
Status: RESOLVED FIXED
Product: gedit
Classification: Applications
Component: file loading and saving
3.11.x
Other Linux
: Normal normal
: ---
Assigned To: Gedit maintainers
Gedit maintainers
Depends on:
Blocks:
 
 
Reported: 2013-03-04 08:55 UTC by Milan Bouchet-Valat
Modified: 2014-07-09 12:08 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Text file to reproduce the bug (564.85 KB, text/x-log)
2013-03-04 08:55 UTC, Milan Bouchet-Valat
Details
File with invalid text (7 bytes, text/plain)
2013-11-03 21:19 UTC, Sébastien Wilmet
Details

Description Milan Bouchet-Valat 2013-03-04 08:55:17 UTC
Created attachment 237936 [details]
Text file to reproduce the bug

Today I edited the attached /var/log/messages using gedit. When saving, gedit noticed that null characters were present, and that could likely corrupt the saved file. So far, so good.

The problem is, even if I used File->Save As, gedit saved the file to the original location, which would have destroyed my system log (I know, gedit as root is total crack !).

The point is, you try to do something very smart, and you end up destroying user data! Life is hard.
Comment 1 Milan Bouchet-Valat 2013-03-04 08:57:12 UTC
Comment on attachment 237936 [details]
Text file to reproduce the bug

Nevermind, saving it from gedit, I managed to lose these null characters. I guess you know how to recreate them... ;-)
Comment 2 Sébastien Wilmet 2013-11-03 21:19:22 UTC
Created attachment 258882 [details]
File with invalid text

I confirm the bug. I attach an invalid file.
Comment 3 Sébastien Wilmet 2013-11-04 18:25:26 UTC
In gedit-tab.c, _gedit_tab_save_as() calls gedit_document_save_as() with lots of parameters: location, encoding, newline type, compression type, and some flags.

Then the document_saved() callback is called with the GEDIT_DOCUMENT_ERROR_CONVERSION_FALLBACK error. The info bar is created, and when we click on the Save Anyway button, the invalid_character_info_bar_response() callback is called. The latter calls gedit_document_save(), not gedit_document_save_as()...

The problem: it seems that all the parameters for save_as() are not saved. There is tmp_save_location and tmp_encoding. But not for the others.

It would be nice to setup an object with all the settings, and keep this object around, instead of copying the parameters.
Comment 4 Sébastien Wilmet 2014-07-09 12:08:49 UTC
This should be fixed in the git master branch, with the new file loading and saving code.