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 559094 - CRLF issue in Windows/Unix Synchronization
CRLF issue in Windows/Unix Synchronization
Status: RESOLVED FIXED
Product: tomboy
Classification: Applications
Component: General
0.13.x
Other Windows
: Normal blocker
: ---
Assigned To: Tomboy Maintainers
Tomboy Maintainers
Depends on:
Blocks:
 
 
Reported: 2008-11-03 12:26 UTC by Kevin Loehmann
Modified: 2009-04-23 02:14 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Proposed fix (6.17 KB, patch)
2008-12-15 03:19 UTC, Sandy Armstrong
needs-work Details | Review
Less satisfying but more effective patch (5.49 KB, patch)
2008-12-15 15:33 UTC, Sandy Armstrong
committed Details | Review

Description Kevin Loehmann 2008-11-03 12:26:05 UTC
Synchronization between Windows and Unix based OS's does not work. Windows saves Files on a local directory (in my case a samba share) with CRLF as Line delimiter. Note-Files with this line delimiter cannot be read by Tomboy under Linux. The problem appears the other way around, too. After performing a dos2unix conversion (in cae of windows-written files) notes can be imported by linux version of tomboy. Again, same thing the other way around (uni2dos with linux-written files).
Comment 1 Sandy Armstrong 2008-11-03 15:18:14 UTC
Hmm, good catch.  I was pretty sure I'd tested this, but clearly I need to push it harder.
Comment 2 Sandy Armstrong 2008-12-01 21:22:27 UTC
What kind of synchronization are you doing?  I cannot reproduce this problem.  I have a server I use for sync; on Linux I use the SSH sync add-in and on Windows I mount the server using samba and use the Local Folder sync add-in.
Comment 3 Kevin Loehmann 2008-12-02 08:22:17 UTC
I tried it with a Windows 2000 Client (German, Charset CP1252) and a local folder sync via a samba share. On the Linux side i used Ubuntu 8.04 (German locale, Charset UTF-8) and sync via ssh. I also tried it with local folder sync via a samba mount on the Linux side. I created the notes on the Windows machine first and tried to read them on the Linux side.
Comment 4 Sandy Armstrong 2008-12-02 15:12:48 UTC
(In reply to comment #3)
> I created the notes on the Windows machine
> first and tried to read them on the Linux side.

Dang, I can totally reproduce it now.  Thanks for your help.
Comment 5 Sandy Armstrong 2008-12-15 03:19:07 UTC
Created attachment 124695 [details] [review]
Proposed fix

So this patch seems to fix it.  The only functional change is specifying the newline character that is used when writing out our XML (for both notes and other shared file types, like sync manifests).

This is implemented using XmlWriterSettings, which necessitated a switch from directly instantiating XmlTextWriters to using XmlWriter.Create instead.  Everything seems to be working fine though, with the patch applied on both Windows and Linux.

I'll test a bit more before committing.  If anybody else wants to review before the release tomorrow, that would be nice.
Comment 6 Sandy Armstrong 2008-12-15 03:36:22 UTC
Nevermind, I'm seeing some issues...this patch is not quite ready.
Comment 7 Sandy Armstrong 2008-12-15 03:37:52 UTC
[DEBUG]: Saving 'Start Here'...
A first chance exception of type 'System.ArgumentException' occurred in System.Xml.dll
[ERROR]: Exception while saving note: System.ArgumentException: Invalid name character in 'link:broken'. The ':' character, hexadecimal value 0x3A, cannot be included in a name.
   at System.Xml.XmlWellFormedWriter.CheckNCName(String ncname)
   at System.Xml.XmlWellFormedWriter.WriteStartElement(String prefix, String localName, String ns)
   at Tomboy.NoteTag.Write(XmlWriter xml, Boolean start) in C:\Users\sandy\Desktop\tomboy\Tomboy\NoteTag.cs:line 167
   at Tomboy.NoteBufferArchiver.WriteTag(TextTag tag, XmlWriter xml, Boolean start) in C:\Users\sandy\Desktop\tomboy\Tomboy\NoteBuffer.cs:line 1150
   at Tomboy.NoteBufferArchiver.Serialize(TextBuffer buffer, TextIter start, TextIter end, XmlWriter xml) in C:\Users\sandy\Desktop\tomboy\Tomboy\NoteBuffer.cs:line 1254
   at Tomboy.NoteBufferArchiver.Serialize(TextBuffer buffer, TextIter start, TextIter end) in C:\Users\sandy\Desktop\tomboy\Tomboy\NoteBuffer.cs:line 1140
   at Tomboy.NoteBufferArchiver.Serialize(TextBuffer buffer) in C:\Users\sandy\Desktop\tomboy\Tomboy\NoteBuffer.cs:line 1130
   at Tomboy.NoteDataBufferSynchronizer.SynchronizeText() in C:\Users\sandy\Desktop\tomboy\Tomboy\Note.cs:line 294
   at Tomboy.NoteDataBufferSynchronizer.GetDataSynchronized() in C:\Users\sandy\Desktop\tomboy\Tomboy\Note.cs:line 238
   at Tomboy.Note.Save() in C:\Users\sandy\Desktop\tomboy\Tomboy\Note.cs:line 500
Comment 8 Sandy Armstrong 2008-12-15 03:48:04 UTC
Doesn't look like I can turn this off in the settings object:

From MSDN: "Character checking does not include checking for illegal characters in XML names, nor does it include checking that all XML names are valid. These checks are part of conformance checking and are always performed."

The error in comment #7 doesn't occur in Mono on Linux, which I guess is technically a bug.

So I need to either change the name of the "link:broken" element (yuck, versioning), cheat and use xml.WriteElement ("link", "broken", null), or go back to using XmlTextWriter, and use some other method to fix the line endings (string.replace, or something like that).
Comment 9 Sandy Armstrong 2008-12-15 04:17:52 UTC
Although using ":" in an XML element name is considered bad form (because it is used for namespaces), it is not illegal.  Microsoft's parser is being overly strict.  So I don't feel too bad about continuing to use ":" in our element names.
Comment 10 Sandy Armstrong 2008-12-15 15:33:21 UTC
Created attachment 124731 [details] [review]
Less satisfying but more effective patch

This one seems to work a lot better.  I had to revert to using XmlTextWriter in a lot of places, and in NoteBufferArchiver I added a string.Replace for non-\n newlines.
Comment 11 Sandy Armstrong 2008-12-15 17:52:34 UTC
Patch committed in r2254.