Index: gtkhtml/htmltokenizer.c
===================================================================
--- gtkhtml/htmltokenizer.c	(revision 9114)
+++ gtkhtml/htmltokenizer.c	(working copy)
@@ -41,7 +41,6 @@ enum {
 static guint html_tokenizer_signals[HTML_TOKENIZER_LAST_SIGNAL] = { 0 };
 
 #define TOKEN_BUFFER_SIZE (1 << 10)
-#define INVALID_CHARACTER_MARKER '?'
 
 #define dt(x)
 
@@ -470,11 +469,13 @@ html_tokenizer_convert_entity (gchar *to
 		if (read_pos < full_pos)
 			if (*read_pos == '&') {
 				/*value to add*/
-				gunichar value = INVALID_CHARACTER_MARKER;
+				gunichar value = INVALID_ENTITY_CHARACTER_MARKER;
 				/*skip not needed &*/
 				read_pos ++;
 				count_chars = strcspn (read_pos, ";");
 				if (count_chars < 14 && count_chars > 1) {
+					/*save for recovery*/
+					gchar save_gchar = *(read_pos + count_chars);
 					*(read_pos + count_chars)=0;
 					/* &#******; */
 					if (*read_pos == '#') {
@@ -488,9 +489,18 @@ html_tokenizer_convert_entity (gchar *to
 					} else {
 						value = html_entity_parse (read_pos, strlen (read_pos));
 					}
-					read_pos += (count_chars + 1);
-					write_pos += g_unichar_to_utf8 (value, write_pos);
+					if(value != INVALID_ENTITY_CHARACTER_MARKER){							
+						write_pos += g_unichar_to_utf8 (value, write_pos);
+						read_pos += (count_chars + 1);
+					} else {
+						/*recovery old value - it's not entity*/
+						write_pos += g_unichar_to_utf8 ('&', write_pos);
+						*(read_pos + count_chars) = save_gchar;
+					}					
 				}
+				else
+					/*very large string*/
+					write_pos += g_unichar_to_utf8 ('&', write_pos);
 			}
 	}
 	*write_pos = 0;
@@ -527,7 +537,7 @@ convert_text_encoding (const GIConv icon
 			g_iconv (iconv_cd, (gchar **)&current, &currlength, &newbuffer, &newlength);
 			if (currlength > 0) {
 				g_warning ("IconvError=%s", current);
-				*newbuffer = INVALID_CHARACTER_MARKER;
+				*newbuffer = INVALID_ENTITY_CHARACTER_MARKER;
 				newbuffer ++;
 				current ++;
 				currlength --;
Index: gtkhtml/ChangeLog
===================================================================
--- gtkhtml/ChangeLog	(revision 9114)
+++ gtkhtml/ChangeLog	(working copy)
@@ -1,3 +1,13 @@
+2009-01-23  Denis Pauk  <pauk.denis@gmail.com>
+
+	** Fix for bug #567697
+
+	* htmlentity.h: (INVALID_ENTITY_CHARACTER_MARKER):
+	* htmlentity.c: (html_entity_parse):
+	* htmltokenizer.c: (html_tokenizer_convert_entity),
+	(convert_text_encoding):
+	Do not strip invalid entities, rather return them back as text.
+
 2009-01-22  Bharath Acharya  <abharath@novell.com>
 
 	** Fix for bug #465432 (BNC)
Index: gtkhtml/htmlentity.c
===================================================================
--- gtkhtml/htmlentity.c	(revision 9114)
+++ gtkhtml/htmlentity.c	(working copy)
@@ -870,6 +870,6 @@ html_entity_parse (const gchar *s, guint
 {
 	struct _EntityEntry * result = html_entity_hash( s, len);
 	if (result == NULL )
-		return ' ';
+		return INVALID_ENTITY_CHARACTER_MARKER;
 	return result->value;
 }
Index: gtkhtml/htmlentity.h
===================================================================
--- gtkhtml/htmlentity.h	(revision 9114)
+++ gtkhtml/htmlentity.h	(working copy)
@@ -30,6 +30,7 @@
 /* We name it with correct unicode name, but OK, later... Lauris */
 /* char used for &nbsp; - must correspond to table below */
 #define ENTITY_NBSP 160
+#define INVALID_ENTITY_CHARACTER_MARKER '?'
 #define IS_UTF8_NBSP(s) (*s == (guchar)0xc2 && *(s + 1) == (guchar)0xa0)
 
 gulong html_entity_parse (const gchar *s, guint len);
