[bijiben] tomboyReader: do not fail on html reserved characters



commit 668deeeaf334977630652a2495c953233636bbed
Author: Pierre-Yves Luyten <py luyten fr>
Date:   Wed Oct 2 23:08:15 2013 +0200

    tomboyReader: do not fail on html reserved characters
    
    See 708812

 src/libbiji/deserializer/biji-tomboy-reader.c |   18 ++++++++++++++----
 1 files changed, 14 insertions(+), 4 deletions(-)
---
diff --git a/src/libbiji/deserializer/biji-tomboy-reader.c b/src/libbiji/deserializer/biji-tomboy-reader.c
index eb5da2d..ed8cdf3 100644
--- a/src/libbiji/deserializer/biji-tomboy-reader.c
+++ b/src/libbiji/deserializer/biji-tomboy-reader.c
@@ -159,16 +159,24 @@ process_tomboy_end_elem (BijiTomboyReader *self)
 static void
 process_tomboy_text_elem (BijiTomboyReader *self)
 {
-  const gchar *text;
+  gchar *text, *html_txt;
   BijiTomboyReaderPrivate *priv = self->priv;
 
-  text = (const gchar *) xmlTextReaderConstValue (priv->inner);
+  text = (gchar*) xmlTextReaderConstValue (priv->inner);
 
   /* Simply append the text to both raw & html
    * FIXME : escape things for html */
 
   priv->raw_text = g_string_append (priv->raw_text, text);
-  priv->html = g_string_append (priv->html, text);
+
+  html_txt  =  biji_str_mass_replace (text,
+                                    "&",  "&amp;",
+                                    "<" , "&lt;" ,
+                                    ">",  "&gt;",
+                                    NULL);
+
+  priv->html = g_string_append (priv->html, html_txt);
+  g_free (html_txt);
 }
 
 
@@ -514,7 +522,9 @@ biji_tomboy_reader_read (gchar *source,
   self = biji_tomboy_reader_new (source);
   priv = self->priv;
 
-  html_revamped = biji_str_replace (priv->html->str, "\n", "<br/>");
+  html_revamped = biji_str_mass_replace (priv->html->str,
+                                         "\n", "<br/>",
+                                         NULL);
 
   *error = priv->error;
   *set = priv->set;


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