GNOME Bugzilla – Bug 559094
CRLF issue in Windows/Unix Synchronization
Last modified: 2009-04-23 02:14:21 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).
Hmm, good catch. I was pretty sure I'd tested this, but clearly I need to push it harder.
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.
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.
(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.
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.
Nevermind, I'm seeing some issues...this patch is not quite ready.
[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
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).
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.
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.
Patch committed in r2254.