[tomboy] Properly encode/decode note title for XML and JSON.



commit 11539e590aa22102cd3637f272e4721af8021ec8
Author: Sandy Armstrong <sanfordarmstrong gmail com>
Date:   Sat May 23 21:34:57 2009 -0700

    Properly encode/decode note title for XML and JSON.
---
 Tomboy/Addins/WebSyncService/NoteConvert.cs |   16 +++++++++++++---
 1 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/Tomboy/Addins/WebSyncService/NoteConvert.cs b/Tomboy/Addins/WebSyncService/NoteConvert.cs
index a64983d..76e3a48 100644
--- a/Tomboy/Addins/WebSyncService/NoteConvert.cs
+++ b/Tomboy/Addins/WebSyncService/NoteConvert.cs
@@ -40,7 +40,12 @@ namespace Tomboy.WebSync
 			NoteInfo noteInfo = new NoteInfo ();
 			
 			noteInfo.Guid = note.Id;
-			noteInfo.Title = note.Title;
+			noteInfo.Title = note.Title
+				.Replace ("&", "&amp;")
+				.Replace ("<", "&lt;")
+				.Replace (">", "&gt;")
+				.Replace ("\"", "&quot;")
+				.Replace ("\'", "&apos;");
 			noteInfo.OpenOnStartup = note.IsOpenOnStartup;
 			noteInfo.Pinned = note.IsPinned;
 			noteInfo.CreateDate = note.CreateDate;
@@ -105,10 +110,15 @@ namespace Tomboy.WebSync
 			//       Guid, Title, NoteContent, and NoteContentVersion
 			// TODO: Is this true? What happens if dates are excluded?
 			NoteData noteData = new NoteData (NoteUriFromGuid (noteInfo.Guid));
-			noteData.Title = noteInfo.Title;
+			noteData.Title = noteInfo.Title
+				.Replace ("&amp;", "&")
+				.Replace ("&lt;", "<")
+				.Replace ("&gt;", ">")
+				.Replace ("&quot;", "\"")
+				.Replace ("&apos;", "\'");
 			noteData.Text = string.Format ("<note-content version=\"{0}\">{1}\n\n{2}</note-content>",
 				noteInfo.NoteContentVersion,
-				noteData.Title,
+				noteInfo.Title,
 				noteInfo.NoteContent);
 			if (noteInfo.LastChangeDate.HasValue)
 				noteData.ChangeDate = noteInfo.LastChangeDate.Value;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]