1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2024-10-26 12:25:09 +03:00
Commit Graph

122 Commits

Author SHA1 Message Date
Nick Wellnhofer
13ad8736d2 Fix regression in xmlNodeDumpOutputInternal
Commit 85b1792e could cause additional whitespace if xmlNodeDump was
called with a non-zero starting level.
2021-05-25 11:16:13 +02:00
Nick Wellnhofer
85b1792e37 Work around lxml API abuse
Make xmlNodeDumpOutput and htmlNodeDumpFormatOutput work with corrupted
parent pointers. This used to work with the old recursive code but the
non-recursive rewrite required parent pointers to be set correctly.

Unfortunately, lxml relies on the old behavior and passes subtrees with
a corrupted structure. Fall back to a recursive function call if an
invalid parent pointer is detected.

Fixes #255.
2021-05-21 12:19:25 +02:00
Nick Wellnhofer
0b3c64d9f2 Handle dumps of corrupted documents more gracefully
Check parent pointers for NULL after the non-recursive rewrite of the
serialization code. This avoids segfaults with corrupted documents
which can apparently be seen with lxml, see issue #187.
2020-09-29 18:08:37 +02:00
Nick Wellnhofer
00a86d414b Don't add formatting newlines to XInclude nodes 2020-08-17 01:17:39 +02:00
Nick Wellnhofer
1a360c1c2e More *NodeDumpOutput fixes
When leaving nodes, restrict more operations to XML_ELEMENT_NODEs.
2020-07-29 00:39:15 +02:00
Nick Wellnhofer
7b2e517261 Fix *NodeDumpOutput functions
Only output end tag for elements. Should fix serialization of document
fragments.
2020-07-28 21:52:55 +02:00
Nick Wellnhofer
dc6f009280 Make xmlNodeDumpOutputInternal non-recursive
Fixes stack overflow with deeply nested documents.
2020-07-28 21:00:09 +02:00
Nick Wellnhofer
5330153da4 Make xhtmlNodeDumpOutput non-recursive
Fixes stack overflow with deeply nested documents.
2020-07-28 21:00:09 +02:00
Nick Wellnhofer
20c60886e4 Fix typos
Resolves #133.
2020-03-08 17:41:53 +01:00
Nick Wellnhofer
c9faa29259 Fix overflow check in xmlNodeDump
Store return value of xmlBufNodeDump in a size_t before checking for
integer overflow.

Found by lgtm.com
2020-01-02 14:12:39 +01:00
Nick Wellnhofer
42942066e1 Fix memory leaks of encoding handlers in xmlsave.c
Fix leak of iconv/ICU encoding handler in xmlSaveToBuffer.

Fix leaks of iconv/ICU encoding handlers in xmlSaveTo* error paths.

Closes #127.
2019-11-11 14:04:57 +01:00
Jared Yanovich
2a350ee9b4 Large batch of typo fixes
Closes #109.
2019-09-30 18:04:38 +02:00
Jan Pokorný
81958b6e94 Doc: do not mislead towards "infeasible" scenario wrt. xmlBufNodeDump
At least when merely public API is to be leveraged, one cannot use
xmlBufCreate function that would otherwise be a clear fit, and relying
on some invariants wrt. how some other struct fields will get
initialized along the construction/filling such parent struct and
(ab)using that instead does not appear clever, either.

Hence, instruct people what's the Right Thing for the moment, that is,
make them use xmlNodeDumpOutput instead (together with likewise public
xmlAllocOutputBuffer).

Going forward, it's questionable what do with xmlBuf* family of
functions that are once public, since they, for any practical purpose,
cannot be used by the library clients (that's how I've run into this).

Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
2019-08-25 13:23:49 +02:00
Nick Wellnhofer
96125557b6 Remove unused member doc in xmlSaveCtxt 2019-05-10 12:30:03 +02:00
Nick Wellnhofer
ee501f5449 Stop using doc->charset outside parser code
doc->charset does not specify the in-memory encoding which is always
UTF-8.
2018-10-13 16:47:01 +02:00
Nick Wellnhofer
cb5541c9f3 Fix libz and liblzma detection
If libz or liblzma are detected with pkg-config, AC_CHECK_HEADERS must
not be run because the correct CPPFLAGS aren't set. It is actually not
required have separate checks for LIBXML_ZLIB_ENABLED and HAVE_ZLIB_H.
Only check for LIBXML_ZLIB_ENABLED and remove HAVE_ZLIB_H macro.

Fixes bug 764657, bug 787041.
2017-11-27 14:33:37 +01:00
Nick Wellnhofer
359e750482 Fix -Wmisleading-indentation warnings 2017-11-27 13:42:30 +01:00
Nick Wellnhofer
362b322934 Fix memory leak in xmlBufAttrSerializeTxtContent
The serializer sets doc->encoding to a temporary value and restores
the original value when it's done. This overwrites the encoding value
set in xmlBufAttrSerializeTxtContent, causing a memory leak.

Don't mess with doc->encoding if invalid UTF-8 is encountered.

Found with libFuzzer and ASan.
2017-06-07 19:58:20 +02:00
Daniel Veillard
c97750d11b Avoid an out of bound access when serializing malformed strings
For https://bugzilla.gnome.org/show_bug.cgi?id=766414

* xmlsave.c: xmlBufAttrSerializeTxtContent() if an attribute value
  is not UTF-8 be more careful when serializing it as we may do an
  out of bound access as a result.
2016-05-23 13:42:18 +08:00
Daniel Veillard
23922c536c When calling xmlNodeDump make sure we grow the buffer quickly
Make sure the underlying new buffer allocated use a double-it scheme
for the time of the dump.
2013-02-11 12:01:05 +08:00
Daniel Veillard
f8e3db0445 Big space and tab cleanup
Remove all space before tabs and space and tabs at end of lines.
2012-09-11 13:26:36 +08:00
Daniel Veillard
3e62adbe39 Adding various checks on node type though the API
Specifially checking against namespace nodes before accessing node
pointers
2012-08-09 14:24:02 +08:00
Daniel Veillard
50cdab5552 New saving functions using xmlBuf and conversion
* save.h: new header providing new functions currently internal
          and xmlBuf counterparts of old xmlBuffer based ones
* xmlsave.c: convert functions to use xmlBuf as much as possible
2012-07-23 14:24:27 +08:00
Daniel Veillard
0795348aeb fix a pair of possible out of array char references
When serializing char references back to an character string
Reported by Abhishek Arya <inferno@chromium.org>
2012-01-22 17:42:35 +08:00
Adam Spragg
d2e62311cd Add xmlSaveOption XML_SAVE_WSNONSIG
non destructive indentation option using spaces within markup
constructs and hence not modifying content
* include/libxml/xmlsave.h: new option
* xmlsave.c: some refactoring and new code for the new option
* xmllint.c: adds --pretty option where option 2 uses the new formatting
2010-11-03 15:33:40 +01:00
Adam Spragg
8b877135a3 Force _xmlSaveCtxt.format to be 0 or 1
* xmlsave.c: force _xmlSaveCtxt.format to be 0 or 1 and check
  accordingly, this will allow other values of "format" to be used
  for other purposes.
2010-11-01 14:24:56 +01:00
Daniel Veillard
594e5dfb48 Chasing dead assignments reported by clang-scan
* SAX2.c dict.c error.c hash.c nanohttp.c parser.c python/libxml.c
  relaxng.c runtest.c tree.c valid.c xinclude.c xmlregexp.c xmlsave.c
  xmlschemas.c xpath.c xpointer.c: mostly removing unneded affectations,
  but this led to a few real bugs and some part not yet understood
  (relaxng/interleave)
2009-09-07 14:58:47 +02:00
Daniel Veillard
141ebfa028 Wrong block opening in htmlNodeDumpOutputInternal
* xmlsave.c: Jim Meyering ran clang on libxml2 and this is one of
  the error found, misplaced curly brace
2009-09-02 14:58:13 +02:00
Daniel Veillard
856d92818b new options to serialize as XML/HTML/XHTML and restore old entry point
* include/libxml/xmlsave.h xmlsave.c: new options to serialize
  as XML/HTML/XHTML and restore old entry point behaviours
Daniel

svn path=/trunk/; revision=3794
2008-09-25 14:31:40 +00:00
Daniel Veillard
da3fee406d Borland C fix from Moritz Both regenerate, workaround a problem for buffer
* trionan.c: Borland C fix from Moritz Both
* testapi.c: regenerate, workaround a problem for buffer testing
* xmlIO.c HTMLtree.c: new internal entry point to hide even better
  xmlAllocOutputBufferInternal
* tree.c: harden the code around buffer allocation schemes
* parser.c: restore the warning when namespace names are not absolute
  URIs
* runxmlconf.c: continue regression tests if we get the expected
  number of errors
* Makefile.am: run the python tests on make check
* xmlsave.c: handle the HTML documents and trees
* python/libxml.c: convert python serialization to the xmlSave APIs
  and avoid some horrible hacks
Daniel

svn path=/trunk/; revision=3790
2008-09-01 13:08:57 +00:00
Daniel Veillard
d0d2f090dc fix handling of empty CDATA nodes as reported and discussed around #514181
* xmlsave.c parser.c: fix handling of empty CDATA nodes as 
  reported and discussed around #514181 and associated patches
* test/emptycdata.xml result/emptycdata.xml* 
  result/noent/emptycdata.xml: added a specific test in the
  regression suite.
Daniel

svn path=/trunk/; revision=3701
2008-03-07 16:50:21 +00:00
Daniel Veillard
a76a81f638 fix to avoid a crash when dumping an attribute from an XHTML document,
* xmlsave.c: fix to avoid a crash when dumping an attribute from
  an XHTML document, patch contributed to fix #485298
Daniel

svn path=/trunk/; revision=3660
2007-10-10 08:28:18 +00:00
Daniel Veillard
3814a365d6 fixed problem reported on bug #460415 Daniel
* xmlsave.c: fixed problem reported on bug #460415
Daniel

svn path=/trunk/; revision=3646
2007-07-26 11:41:46 +00:00
William M. Brack
38d452ac1c Fixed typo in xmlCharEncFirstLine pointed out by Mark Rowe (bug #440159)
* encoding.c: Fixed typo in xmlCharEncFirstLine pointed out
  by Mark Rowe (bug #440159)
* include/libxml/xmlversion.h.in: Added check for definition of
  _POSIX_C_SOURCE to avoid warnings on Apple OS/X (patch from
  Wendy Doyle and Mark Rowe, bug #346675)
* schematron.c, testapi.c, tree.c, xmlIO.c, xmlsave.c: minor
  changes to fix compilation warnings - no change to logic.

svn path=/trunk/; revision=3618
2007-05-22 16:00:06 +00:00
Daniel Veillard
bd44484bb0 applied patch from Björn Wiberg to try to fix again the silly
* nanoftp.c: applied patch from Björn Wiberg to try to fix again
  the silly __ss_familly problem on various AIXes, should fix #420184
Daniel

svn path=/trunk/; revision=3592
2007-03-20 08:47:29 +00:00
Daniel Veillard
dab39b568a started to switch xmllint to use xmlSaveDoc to test #342556 fixed #342556
* xmllint.c: started to switch xmllint to use xmlSaveDoc to test
  #342556
* xmlsave.c: fixed #342556 easy and a whole set of problems with
  encodings, BOM and xmlSaveDoc()
Daniel
2006-10-16 23:22:10 +00:00
Daniel Veillard
681e904e37 fixed a comment applied a patch from Michael Day to add a new function
* xmlsave.c: fixed a comment
* xinclude.c include/libxml/xinclude.h: applied a patch from Michael Day
  to add a new function providing the _private field for the generated
  parser contexts xmlXIncludeProcessFlagsData()
Daniel
2006-09-29 09:16:00 +00:00
Rob Richards
417b74d0b1 Add linefeeds to error messages allowing for consistant handling.
* HTMLtree.c xmlsave.c: Add linefeeds to error messages allowing
  for consistant handling.
2006-08-15 23:14:24 +00:00
Kasimier T. Buchcik
7b4e2e20fd Removed the automatic generation of CDATA sections for the content of the
* xmlsave.c: Removed the automatic generation of CDATA sections
  for the content of the "script" and "style" elements when
  serializing XHTML. The issue was reported by Vincent Lefevre,
  bug #345147.
* result/xhtml1 result/noent/xhtml1: Adjusted regression test
  results due to the serialization change described above.
2006-07-13 13:07:11 +00:00
Daniel Veillard
9a00fd2991 applied patch from Geert Jansen to implement the save function to a
* xmlsave.c xmlIO.c include/libxml/xmlIO.h include/libxml/xmlsave.h:
  applied patch from Geert Jansen to implement the save function to
  a xmlBuffer, and a bit of cleanup.
Daniel
2005-11-09 08:56:26 +00:00
Rob Richards
2e2691b51c prevent output of fragment tags when serializing XHTML.
* xmlsave.c: prevent output of fragment tags when serializing XHTML.
2005-10-21 14:45:16 +00:00
Daniel Veillard
33b20b70e2 release of 2.6.22 updated doc and rebuild. added XML_SAVE_NO_XHTML
* NEWS configure.in doc//*: release of 2.6.22 updated doc and
  rebuild.
* xmlsave.c include/libxml/xmlsave.h: added XML_SAVE_NO_XHTML
  xmlSaveOption
* xmlschemas.c: minor cleanups
Daniel
2005-09-12 21:43:20 +00:00
Daniel Veillard
dbd6105321 applied second patch from David Madore to be less intrusive when handling
* xmlsave.c: applied second patch from David Madore to be less intrusive
  when handling scripts and style elements in XHTML1 should fix #316041
* test/xhtml1 result//xhtml1\*: updated the test accordingly
Daniel
2005-09-12 14:03:26 +00:00
Rob Richards
2ce51c0646 add XML_SAVE_NO_EMPTY save option and use option from xmlSaveCtxtPtr
* include/libxml/xmlsave.h xmlsave.c: add XML_SAVE_NO_EMPTY save option
  and use option from xmlSaveCtxtPtr rather than global during output.
* xmlsave.c: fix some output formatting for meta element under XHTML.
2005-09-12 12:16:35 +00:00
Daniel Veillard
60071aecb3 fix bug #316034, where xmlElemDump() can crash if given a document pointer
* xmlsave.c: fix bug #316034, where xmlElemDump() can crash if
  given a document pointer instead of an element
Daniel
2005-09-12 00:03:43 +00:00
Rob Richards
07b7200775 check for NULL to prevent crash with meta elements
* xmlsave.c: check for NULL to prevent crash with meta elements
2005-09-03 14:56:36 +00:00
Rob Richards
31f73028a2 move handling of meta element for http-equiv in XHTML docs to
* xmlsave.c: move handling of meta element for http-equiv in XHTML docs to
  serialization and no longer modify internal tree.
2005-08-26 15:33:26 +00:00
Daniel Veillard
100e18030d fixed #145092 by adding an xmlSaveOption to omit XML declaration Daniel
* xmlsave.c include/libxml/xmlsave.h: fixed #145092 by adding
  an xmlSaveOption to omit XML declaration
Daniel
2005-08-08 14:44:11 +00:00
Daniel Veillard
7cd517c262 applied patch from Mark Vakoc fixing saving of CDATA with NULL content.
* xmlsave.c: applied patch from Mark Vakoc fixing saving of
  CDATA with NULL content.
Daniel
2005-05-20 18:47:22 +00:00
Daniel Veillard
5d4644ef6e revamped the elfgcchack.h format to cope with gcc4 change of aliasing
* doc/apibuild.py doc/elfgcchack.xsl: revamped the elfgcchack.h
  format to cope with gcc4 change of aliasing allowed scopes, had
  to add extra informations to doc/libxml2-api.xml to separate
  the header from the c module source.
* *.c: updated all c library files to add a #define bottom_xxx
  and reimport elfgcchack.h thereafter, and a bit of cleanups.
* doc//* testapi.c: regenerated when rebuilding the API
Daniel
2005-04-01 13:11:58 +00:00
Daniel Veillard
64354ea7d6 fixed bug reported by Petr Pajas, in the absence of encoding UTF-8 should
* xmlsave.c: fixed bug reported by Petr Pajas, in the absence of
  encoding UTF-8 should really be assumed. This may break if
  the HTTP headers indicates for example ISO-8859-1 since this
  then becomes a well formedness error.
Daniel
2005-03-31 15:22:56 +00:00
William M. Brack
12d37ab634 fixed problem when XMLLINT_INDENT was empty (bug 168033). fixed
* xmlsave.c: fixed problem when XMLLINT_INDENT was empty (bug 168033).
* xpath.c: fixed compilation warning, no change to logic.
* xmlschemastypes.c: fixed compilation warning, no change to logic.
2005-02-21 13:54:07 +00:00
William M. Brack
4e1c2db89e fixed compilation warning changed xmlWarningMsg so ctxt->errNo is not set
* dict.c: fixed compilation warning
* parser.c: changed xmlWarningMsg so ctxt->errNo is not set
* xmllint.c: changed to return non-zero status if error
  on xinclude processing
* xmlsave.c: minor deletion of a redundant condition statement
2005-02-11 10:58:55 +00:00
Daniel Veillard
6fc5db0090 trying to fix at least the message from bug #158628 added first xmlsave
* xmlschemastypes.c: trying to fix at least the message from
  bug #158628
* include/libxml/xmlsave.h xmlsave.c: added first xmlsave option
  for format, c.f. bug #159997
Daniel
2005-01-16 00:05:58 +00:00
Daniel Veillard
ce682bc24b autogenerate a minimal NULL value sequence for unknown pointer types This
* gentest.py testapi.c: autogenerate a minimal NULL value sequence
  for unknown pointer types
* HTMLparser.c SAX2.c chvalid.c encoding.c entities.c parser.c
  parserInternals.c relaxng.c valid.c xmlIO.c xmlreader.c
  xmlsave.c xmlschemas.c xmlschemastypes.c xmlstring.c xpath.c
  xpointer.c: This uncovered an impressive amount of entry points
  not checking for NULL pointers when they ought to, closing all
  the open gaps.
Daniel
2004-11-05 17:22:25 +00:00
Daniel Veillard
ce244ad595 fixed the way the generator works, extended the testing, especially with
* gentest.py testapi.c: fixed the way the generator works,
  extended the testing, especially with more real trees and nodes.
* HTMLtree.c tree.c valid.c xinclude.c xmlIO.c xmlsave.c: a bunch
  of real problems found and fixed.
* entities.c: fix error reporting to go through the new handlers
Daniel
2004-11-05 10:03:46 +00:00
Daniel Veillard
3d97e669ec extending the tests coverage more fixes and cleanups Daniel
* gentest.py testapi.c: extending the tests coverage
* HTMLtree.c tree.c xmlsave.c xpointer.c: more fixes and cleanups
Daniel
2004-11-04 10:49:00 +00:00
Daniel Veillard
41c4a753bc fixed 2 problems raised by #152140, one which is that notation not in the
* valid.c xmlsave.c: fixed 2 problems raised by #152140, one
  which is that notation not in the internal subset should
  not be saved, and the second more nasty on an error saving
  NOTATIONs, if there is a proof that nobody uses notations !
Daniel
2004-09-08 20:55:38 +00:00
Daniel Veillard
da3b29a5c4 added a dumb rule to able to compile tst.c when people submit a sample
* Makefile.am: added a dumb rule to able to compile tst.c
  when people submit a sample test program
* xmlschemas.c: applied small patch from Eric Haszlakiewicz
  to document xmlSchemasSetValidErrors() limitations, #141827
* error.c: Add information in generic and structured error
  setter functions that this need to be done per thread #144308
* xmlsave.c: fixed bug whith missing NOTATION(s) serialization
  bug #144162
* doc/xmllint.xml: typo fix #144840
Daniel
2004-08-14 11:15:13 +00:00
Daniel Veillard
a2351322c8 hack based on Arjan van de Ven suggestion to reduce ELF footprint and
* elfgcchack.h doc/elfgcchack.xsl libxml.h: hack based on Arjan van de
  Ven suggestion to reduce ELF footprint and generated code. Based on
  aliasing of libraries function to generate direct call instead of
  indirect ones
* doc/libxml2-api.xml doc/Makefile.am doc/apibuild.py: added automatic
  generation of elfgcchack.h based on the API description, extended
  the API description to show the conditionals configuration flags
  required for symbols.
* nanohttp.c parser.c xmlsave.c include/libxml/*.h: lot of cleanup
* doc/*: regenerated the docs.
Daniel
2004-06-27 12:08:10 +00:00
Daniel Veillard
3995bc3618 start adding API for escaping customization. Daniel
* xmlsave.c include/libxml/xmlsave.h: start adding API for
  escaping customization.
Daniel
2004-05-15 18:57:31 +00:00
Daniel Veillard
7a6361f710 more xmlSave cleanup, optimization and refactoring Daniel
* xmlsave.c: more xmlSave cleanup, optimization and refactoring
Daniel
2004-05-15 16:37:50 +00:00
Daniel Veillard
83a75e05b0 third pass at the escaping refactoring. Daniel
* xmlIO.c xmlsave.c: third pass at the escaping refactoring.
Daniel
2004-05-14 21:50:42 +00:00
Daniel Veillard
ee8960bcab second pass on escaping handling, start to looks better, need to be
* xmlIO.c xmlsave.c include/libxml/xmlIO.h: second pass on escaping
  handling, start to looks better, need to be completed and added
  directly at the saving context level.
Daniel
2004-05-14 03:25:14 +00:00
Daniel Veillard
5d1a4d81bf first pass at refactoring the escape on save routines for better
* xmlIO.c xmlsave.c include/libxml/xmlIO.h: first pass at refactoring
  the escape on save routines for better performances (less malloc)
  and more flexibility using the new saving context. Preliminary
  work, interface will change.
Daniel
2004-05-13 14:31:25 +00:00
Daniel Veillard
f0244cea96 apply fix for XHTML1 formating from Nick Wellnhofer fixes bug #141266
* xmlsave.c: apply fix for XHTML1 formating from Nick Wellnhofer
  fixes bug #141266
* test/xhtmlcomp result//xhtmlcomp*: added the specific regression
  test
Daniel
2004-05-09 23:48:39 +00:00
Daniel Veillard
656ce948ab Fixed bug #141529 i.e. various problems when building with --without-html
* xmllint.c xmlsave.c python/generator.py python/libxml.c: Fixed
  bug #141529 i.e. various problems when building with --without-html
Daniel
2004-04-30 23:11:45 +00:00
Daniel Veillard
e2161a699b fix a nasty problem with reading over the end fix a reported memory leak
* xmlreader.c: fix a nasty problem with reading over the end
* xmlsave.c: fix a reported memory leak apparently
Daniel
2004-04-29 17:14:25 +00:00
Daniel Veillard
377e1a9059 move the TODO as comments as the function while not finished are usable
* xmlsave.c: move the TODO as comments as the function while not
  finished are usable as-is
* xmlschemas.c include/libxml/xmlerror.h: patch from Kasimier Buchcik
  implementing union
* test/schemas/union_0_0.x* result/schemas/union_0_0*: added example
* python/Makefile.am: applied fix from Mike Hommey
Daniel
2004-04-16 16:30:05 +00:00
Daniel Veillard
753086ac9b optimize indentation based on the new context Daniel
* xmlsave.c: optimize indentation based on the new context
Daniel
2004-03-28 16:12:44 +00:00
Daniel Veillard
32b7cdb6b7 switched the output routines to use the new context. Daniel
* xmlsave.c: switched the output routines to use the new context.
Daniel
2004-03-15 13:46:37 +00:00
Daniel Veillard
1a8741c898 commiting the new xmlsave module before the actuall big code change.
* Makefile.am tree.c xmlsave.c include/libxml/xmlsave.h: commiting
  the new xmlsave module before the actuall big code change.
Daniel
2004-03-04 13:40:59 +00:00