Opened 10 years ago

Closed 9 years ago

Last modified 8 years ago

#7519 closed Bugs (fixed)

newlines and tabs are not encoded when writing XML.

Reported by: nicolas.cavallari@… Owned by: Sebastian Redl
Milestone: To Be Determined Component: property_tree
Version: Boost Development Trunk Severity: Problem
Keywords: property_tree xml newline graphml Cc:

Description

This XML file :

<?xml version="1.0" encoding="UTF-8"?>
<somemoredata>hello&#9;world:&#10;Want something?</somemoredata>

Is properly parsed and somedata contains "hello\tworld\nWant something?", but this information is lost when writing:

<somemoredata>Hello	world
Want something?</somemoredata>

Reading that file will yield "Hello world Want something?", so the round trip ate these characters. Instead, write_xml should encode newlines and tabs according to http://www.w3.org/TR/2000/WD-xml-c14n-20000119.html#charescaping.

Boost.Graph's write_graphml() and read_graphml() are also affected by this problem as they reuse property_tree. The attached patch fix the problem for both libraries.

Attachments (1)

boost.patch (654 bytes ) - added by nicolas.cavallari@… 10 years ago.
encode \n and \t when writing XML.

Download all attachments as: .zip

Change History (3)

by nicolas.cavallari@…, 10 years ago

Attachment: boost.patch added

encode \n and \t when writing XML.

comment:1 by Sebastian Redl, 9 years ago

Resolution: fixed
Status: newclosed

Fixed on develop in 4e7aa973f.

Merged to master in 85f8d8866ccf.

comment:2 by Pieter, 8 years ago

This patch broke my existing code. See: https://svn.boost.org/trac/boost/ticket/10338

Note: See TracTickets for help on using tickets.