aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ephy-node.c
diff options
context:
space:
mode:
authorChristian Persch <chpe@svn.gnome.org>2007-01-29 04:06:12 +0800
committerChristian Persch <chpe@src.gnome.org>2007-01-29 04:06:12 +0800
commit819a719f62d6d9583d55b1c5ac787c7f64a03de6 (patch)
treebb8e94165702c9e8c1d5453a42a8d28ec5a5abf1 /lib/ephy-node.c
parent2eee055dd76bfe30aea7758025cdd499aea95b4d (diff)
downloadgsoc2013-epiphany-819a719f62d6d9583d55b1c5ac787c7f64a03de6.tar
gsoc2013-epiphany-819a719f62d6d9583d55b1c5ac787c7f64a03de6.tar.gz
gsoc2013-epiphany-819a719f62d6d9583d55b1c5ac787c7f64a03de6.tar.bz2
gsoc2013-epiphany-819a719f62d6d9583d55b1c5ac787c7f64a03de6.tar.lz
gsoc2013-epiphany-819a719f62d6d9583d55b1c5ac787c7f64a03de6.tar.xz
gsoc2013-epiphany-819a719f62d6d9583d55b1c5ac787c7f64a03de6.tar.zst
gsoc2013-epiphany-819a719f62d6d9583d55b1c5ac787c7f64a03de6.zip
Make sure we don't write characters < 0x20 (except 0x9, 0xa, 0xd) to XML.
2007-01-28 Christian Persch <chpe@svn.gnome.org> * lib/ephy-node.c: (safe_write_string), (ephy_node_write_to_xml): * src/bookmarks/ephy-bookmarks-export.c: (sanitise_string), (write_topics_list), (write_rdf): Make sure we don't write characters < 0x20 (except 0x9, 0xa, 0xd) to XML. Bug #392782. svn path=/trunk/; revision=6856
Diffstat (limited to 'lib/ephy-node.c')
-rw-r--r--lib/ephy-node.c34
1 files changed, 33 insertions, 1 deletions
diff --git a/lib/ephy-node.c b/lib/ephy-node.c
index 5581d3322..7078f23b1 100644
--- a/lib/ephy-node.c
+++ b/lib/ephy-node.c
@@ -806,6 +806,38 @@ write_parent (guint id,
if (data->ret < 0) return;
}
+static inline int
+safe_write_string (xmlTextWriterPtr writer,
+ const xmlChar *string)
+{
+ int ret;
+ xmlChar *copy, *p;
+
+ if (!string)
+ return 0;
+
+ /* http://www.w3.org/TR/REC-xml/#sec-well-formed :
+ Character Range
+ [2] Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] |
+ [#xE000-#xFFFD] | [#x10000-#x10FFFF]
+ any Unicode character, excluding the surrogate blocks, FFFE, and FFFF.
+ */
+
+ copy = xmlStrdup (string);
+ for (p = copy; *p; p++)
+ {
+ xmlChar c = *p;
+ if (G_UNLIKELY (c < 0x20 && c != 0xd && c != 0xa && c != 0x9)) {
+ *p = 0x20;
+ }
+ }
+
+ ret = xmlTextWriterWriteString (writer, copy);
+ xmlFree (copy);
+
+ return ret;
+}
+
int
ephy_node_write_to_xml(EphyNode *node,
xmlTextWriterPtr writer)
@@ -851,7 +883,7 @@ ephy_node_write_to_xml(EphyNode *node,
switch (G_VALUE_TYPE (value))
{
case G_TYPE_STRING:
- ret = xmlTextWriterWriteString
+ ret = safe_write_string
(writer, (const xmlChar *)g_value_get_string (value));
break;
case G_TYPE_BOOLEAN: