[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
[xml] xmlNodeDump looses data
- From: Petr Pajas <pajas ufal mff cuni cz>
- To: libxml2 <xml gnome org>
- Subject: [xml] xmlNodeDump looses data
- Date: Fri, 15 Feb 2008 16:59:36 +0100
Hi Daniel, All,
one of the users of the Perl bindings reported a strange bug which I
was able to reduce to the attached very very simple "test.c"
program and a XML file "test2.xml".
The program parses the XML file into a tree, and then dumps the root
element using xmlNodeDump.
In the result, a complete text content of a text node within an
element <linkage> is missing.
The behavior depends on various factors:
- the length of the input file (if you add 400 characters before the
<linkage> element, the output is correct)
- if formatting is turned on at xmlNodeDump, the output is correct
(this is probably why the bug cannot be reproduced with the 'cat'
command of xmllint --shell, since the formatting is turned on
there)
- if the complete document is dumped, it is correct.
- if the (about 50) characters <,> (rendered as entities < >)
are replaced with e.g. _, the output is correct
- the output (I'm told) is correct with libxml2 <=2.6.27
- the structure of the document seems to be also important
The bug seems to me rather serious since it can have really bad
consequences for applications that use xmlNodeDump.
Please let me know if you need more information.
-- Petr
/* @(#)test.c
*/
#include <stdio.h>
#include <libxml/tree.h>
#include <libxml/parser.h>
int
main(int argc, char **argv)
{
xmlDoc *doc = NULL;
xmlNode *root_element = NULL;
xmlBufferPtr buffer;
if (argc != 2) {
printf("usage: ./test test2.xml\n");
return 1;
}
LIBXML_TEST_VERSION
doc = xmlReadFile(argv[1], NULL, 0);
if (doc == NULL) {
printf("error: could not parse file %s\n", argv[1]);
}
root_element = xmlDocGetRootElement(doc);
buffer = xmlBufferCreate();
xmlNodeDump( buffer,
doc,
root_element, 0, 0);
printf("%s", xmlBufferContent( buffer ));
xmlBufferFree( buffer );
xmlFreeDoc(doc);
xmlCleanupParser();
return 0;
}
<?xml version="1.0"?>
<testing><game_create game="..." channel="......" owner="......" seq="." _time="................." _source="......" _target="......."/><game_join channel="......" game="..." seq="." _time="................." _source="......" _target="......."><user>______</user></game_join><game_join channel="......" game="..." seq="." _time="................." _source="......" _target="......."><user>______</user></game_join><game_player_settings player="......" channel="......" seq="." _time="................." _source="......" _target="......."><scolor>_____</scolor></game_player_settings><game_player_settings player="......" channel="......" seq="." _time="................." _source="......" _target="......."><scolor>_____</scolor></game_player_settings><game_settings channel="......" seq="." _time="................." _source="......" _target="......."><gameBoardType>________</gameBoardType><boardSize>___</boardSize><gameTurn>_________</gameTurn><gameRandomBeads>________</gameRandomBeads><gameLinkRules>________</gameLinkRules><gameWild>______</gameWild><gameTopic total="..">________</gameTopic></game_settings><game_ready channel="......" seq="." _time="................." _source="......" _target="......."><board dimensions="..." kind="........"><space l="...">_</space><space l="...">_</space><space l="...">___</space><space l="...">_</space><space l="...">_</space><space l="...">___</space><space l="...">_________</space><space l="...">_________</space><space l="...">___</space><space l="...">_______</space><space l="...">_________</space><space l="...">___________</space><space l="...">_________</space><space l="...">_______</space><space l="...">_____</space><space l="...">___________</space><space l="...">___________</space><space l="...">___________</space><space l="...">___________</space><space l="...">_____</space><space l="...">_______</space><space l="...">_________</space><space l="...">___________</space><space l="...">_________</space><space l="...">_______</space><space l="...">___</space><space l="...">_________</space><space l="...">_________</space><space l="...">___</space><space l="...">_</space><space l="...">_</space><space l="...">___</space><space l="...">_</space><space l="...">_</space></board><gameBoardType>________</gameBoardType><boardSize>___</boardSize><gameTurn>_________</gameTurn><gameLinkRules>________</gameLinkRules><gameRandomBeads>________</gameRandomBeads><gameWild>______</gameWild><gameTopic>________</gameTopic><turnTime>___</turnTime></game_ready><game_hand channel="......" game="..." player="......" seq="." _time="................." _source="......" _target="......."><bead/><bead/><bead/><bead/></game_hand><game_hand channel="......" game="..." player="......" seq="." _time="................." _source="......" _target="......."><bead/><bead/><bead/><bead/></game_hand><game_start channel="......" time="............." seq=".." _time="................." _source="......" _target="......."/><game_turn_rotate turn="......" game="..." channel="......" timeleft="" time="............." seq=".." _time="................." _source="......" _target="......."/><game_resume channel="......" time="............." timeleft="......" seq=".." _time="................." _source="......" _target="......."/><game_resume channel="......" time="............." timeleft="......" seq=".." _time="................." _source="......" _target="......."/><game_play_discard player="......" channel="......" seq=".." _time="................." _source="......" _target="......."><bead_play x="." y=".">________</bead_play></game_play_discard><game_deal player="......" channel="......" game="..." seq=".." _time="................." _source="......" _target="......."><bead/></game_deal><game_turn_rotate turn="......" game="..." channel="......" timeleft="" time="............." seq=".." _time="................." _source="......" _target="......."/><game_play channel="......" player="......" time="............." timeleft=".." seq=".." _time="................." _source="......" _target="......."><bead_play x="." y="." bead="........"><link bead="........" x="." y="."/></bead_play><linkage><_____________________________><____________________><_><_><_><______________________________________________________________________>______________<__><__><__><__><_____>____<____________________><_><______________________________________________________________________>_________<__><__><_____><_____><____><____><_____________________________________________><_>_______<__><_____>_<_____________________________>____<_____></linkage></game_play></testing>
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]