After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 464145 - g_markup_escape_text Produces Invalid XML
g_markup_escape_text Produces Invalid XML
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: general
2.13.x
Other All
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2007-08-06 21:19 UTC by Andreas Monitzer
Modified: 2007-08-09 02:07 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Andreas Monitzer 2007-08-06 21:19:51 UTC
Please describe the problem:
g_markup_escape_text does not properly escape characters not allowed in XML using entities.

Steps to reproduce:
1. Create markuptest.c with the following content:

#include <stdio.h>
#include <glib.h>

main() {
	char input[1];
	input[0] = 0x0f;
	
	gchar *out = g_markup_escape_text(input, 1);
	
	return printf("<tag>%s</tag>",out);
}

2. Compile & link it
3. Install libxml2 (if not done already)
4. Run:
./markuptest | xmllint -

Actual results:
-:1: parser error : PCDATA invalid Char value 15
<tag></tag>
     ^



Expected results:
Output of something like <tag>&#x0f;</tag>

Does this happen every time?
yes

Other information:
It's probably necessary to implement the list described in http://www.w3.org/TR/REC-xml/#NT-BaseChar into this function and escape all other characters.
Comment 1 Matthias Clasen 2007-08-07 01:23:54 UTC
I'd much rather follow http://www.w3.org/TR/2006/REC-xml11-20060816/#charsets
which has a much simpler table.
Comment 2 Matthias Clasen 2007-08-09 02:07:48 UTC
2007-08-08  Matthias Clasen  <mclasen@redhat.com>

        * glib/gmarkup.c (append_escaped_text): Handle restricted
        characters by converting them to numeric character
        entities.  (#464145, Andreas Monitzer)

        * tests/markup-escape-test.c: Add tests for restricted
        characters and numeric character entities.