--- imap_object.c.orig	2013-01-06 14:44:54.000000000 +0530
+++ imap_object.c	2013-02-18 17:39:36.000000000 +0530
@@ -23,6 +23,7 @@
 #include "config.h"
 
 #include <gtk/gtk.h>
+#include <string.h>
 
 #include "imap_commands.h"
 #include "imap_default_dialog.h"
@@ -31,6 +32,11 @@
 #include "imap_object.h"
 #include "imap_string.h"
 
+gchar *markup_escape_text (const gchar *text, gssize length);
+int recheck (const gchar *str);
+static void append_escaped_text_p (GString *str, 
+                                   const gchar *text, gssize length);
+
 typedef struct {
    ObjectListCallbackFunc_t func;
    gpointer data;
@@ -983,7 +989,7 @@
                  OutputFunc_t output)
 {
    if (*value) {
-      gchar *escaped_value = g_markup_escape_text(value, -1);
+      gchar *escaped_value = markup_escape_text(value, -1);
       output(param, " %s=\"%s\"", attrib, escaped_value);
       g_free(escaped_value);
    } else if (*default_text) {
@@ -1036,3 +1042,108 @@
       output(param, "\n");
    }
 }
+
+static void
+append_escaped_text_p (GString *str, const gchar *text, gssize length)
+{
+ /* Modified append_escaped_text() */
+  const gchar *p;
+  const gchar *end;
+  gunichar c;
+  gchar d;
+  const gchar *next;
+  p = text;
+  end = text + length;
+  
+  while (p != end)
+    {
+      next = p + 1;
+
+      switch (*p)
+        {
+        case '&':
+          if (recheck (next) == 0)
+            g_string_append (str, "&amp;");
+          break;
+
+        case '<':
+          if (recheck (next) == 0)
+            g_string_append (str, "&lt;");
+          break;
+
+        case '>':
+          if (recheck (next) == 0)
+            g_string_append (str, "&gt;");
+          break;
+
+        case '\'':
+          if (recheck (next) == 0)
+            g_string_append (str, "&apos;");
+          break;
+
+        case '"':
+          if (recheck (next) == 0)
+            g_string_append (str, "&quot;");
+          break;
+
+        default:
+          c = g_utf8_get_char (p);
+          if ((0x1 <= c && c <= 0x8) ||
+              (0xb <= c && c  <= 0xc) ||
+              (0xe <= c && c <= 0x1f) ||
+              (0x7f <= c && c <= 0x84) ||
+              (0x86 <= c && c <= 0x9f))
+            g_string_append_printf (str, "&#x%x;", c);
+          else
+            g_string_append_len (str, p, next - p ); 
+          break;
+        }
+
+      d = *p;
+      if ( (recheck (next) != 0) && (d == '&' || d == '<' || d == '>' || d == '"' || d == '\'') )
+        g_string_append_len (str, p, next - p );
+      p = next;
+    }
+}
+
+
+gchar 
+*markup_escape_text (const gchar *text,
+                           gssize     length)
+{
+ /* Modified g_markup_unescape_text() */
+  GString *str;
+
+  g_return_val_if_fail (text != NULL, NULL);
+
+  if (length < 0)
+    length = strlen (text);
+  str = g_string_sized_new (length);
+  append_escaped_text_p (str, text, length);
+
+  return g_string_free (str, FALSE);
+}
+
+int 
+recheck (const gchar *str)
+{
+ /*
+  *checks the repetition of the escape characters.
+  *returns the index of the the character to be appended to the GString
+  */
+  if (strncmp (str, "amp;", 4) == 0)
+    return 4;
+  else if (strncmp (str, "lt;", 3) == 0)
+    return 3;
+  else if (strncmp (str, "gt;", 3) == 0)
+    return 3;
+  else if (strncmp (str, "apos;", 5) == 0)
+    return 5;
+  else if (strncmp (str, "quot;", 5) == 0)
+    return 5;
+  else if (strncmp (str, "#x", 2) == 0)
+    return 4;
+  else
+    return 0;
+}
+
