summaryrefslogtreecommitdiff
path: root/xmlsave.c
Commit message (Collapse)AuthorAgeFilesLines
* malloc-fail: Fix memory leak in xmlDocDumpFormatMemoryEncNick Wellnhofer2023-02-171-0/+1
| | | | Found with libFuzzer, see #344.
* Move xmlIsXHTML to tree.cNick Wellnhofer2022-09-021-44/+1
| | | | | It's declared in tree.h and not guarded by LIBXML_OUTPUT_ENABLED like the other functions in xmlsave.c.
* Remove explicit integer castsNick Wellnhofer2022-09-011-1/+1
| | | | | | | | | | | | | | | | | | | | Remove explicit integer casts as final operation - in assignments - when passing arguments - when returning values Remove casts - to the same type - from certain range-bound values The main motivation is that these explicit casts don't change the result of operations and only render UBSan's implicit-conversion checks useless. Removing these casts allows UBSan to detect cases where truncation or sign-changes occur unexpectedly. Document some explicit casts as truncating and add a few missing ones.
* Consolidate private header filesNick Wellnhofer2022-08-261-8/+8
| | | | | | | | | | | Private functions were previously declared - in header files in the root directory - in public headers guarded with IN_LIBXML - in libxml.h - redundantly in source files that used them. Consolidate all private header files in include/private.
* Avoid calling xmlSetTreeDocNick Wellnhofer2022-06-201-1/+1
| | | | | Create text nodes with xmlNewDocText or set the document directly to avoid xmlSetTreeDoc being called when the node is inserted.
* Improve buffer allocation schemeNick Wellnhofer2022-03-061-0/+4
| | | | | | | In most places, we really need the double-it scheme to avoid quadratic behavior. The hybrid scheme still can cause many reallocations and the bounded scheme doesn't seem to provide meaningful protection in xmlreader.c.
* Remove elfgcchack.hNick Wellnhofer2022-02-201-2/+0
| | | | | The same optimization can be enabled with -fno-semantic-interposition since GCC 5. clang has always used this option by default.
* Fix regression in xmlNodeDumpOutputInternalNick Wellnhofer2021-05-251-7/+7
| | | | | Commit 85b1792e could cause additional whitespace if xmlNodeDump was called with a non-zero starting level.
* Work around lxml API abuseNick Wellnhofer2021-05-211-10/+21
| | | | | | | | | | | | 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.
* Handle dumps of corrupted documents more gracefullyNick Wellnhofer2020-09-291-0/+12
| | | | | | 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.
* Don't add formatting newlines to XInclude nodesNick Wellnhofer2020-08-171-2/+6
|
* More *NodeDumpOutput fixesNick Wellnhofer2020-07-291-22/+22
| | | | When leaving nodes, restrict more operations to XML_ELEMENT_NODEs.
* Fix *NodeDumpOutput functionsNick Wellnhofer2020-07-281-24/+30
| | | | | Only output end tag for elements. Should fix serialization of document fragments.
* Make xmlNodeDumpOutputInternal non-recursiveNick Wellnhofer2020-07-281-230/+240
| | | | Fixes stack overflow with deeply nested documents.
* Make xhtmlNodeDumpOutput non-recursiveNick Wellnhofer2020-07-281-342/+275
| | | | Fixes stack overflow with deeply nested documents.
* Fix typosNick Wellnhofer2020-03-081-2/+2
| | | | Resolves #133.
* Fix overflow check in xmlNodeDumpNick Wellnhofer2020-01-021-1/+1
| | | | | | | Store return value of xmlBufNodeDump in a size_t before checking for integer overflow. Found by lgtm.com
* Fix memory leaks of encoding handlers in xmlsave.cNick Wellnhofer2019-11-111-18/+8
| | | | | | | | Fix leak of iconv/ICU encoding handler in xmlSaveToBuffer. Fix leaks of iconv/ICU encoding handlers in xmlSaveTo* error paths. Closes #127.
* Large batch of typo fixesJared Yanovich2019-09-301-4/+4
| | | | Closes #109.
* Doc: do not mislead towards "infeasible" scenario wrt. xmlBufNodeDumpJan Pokorný2019-08-251-2/+2
| | | | | | | | | | | | | | | | | | 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>
* Remove unused member `doc` in xmlSaveCtxtNick Wellnhofer2019-05-101-11/+0
|
* Stop using doc->charset outside parser codeNick Wellnhofer2018-10-131-3/+0
| | | | | doc->charset does not specify the in-memory encoding which is always UTF-8.
* Fix libz and liblzma detectionNick Wellnhofer2017-11-271-1/+1
| | | | | | | | | 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.
* Fix -Wmisleading-indentation warningsNick Wellnhofer2017-11-271-25/+25
|
* Fix memory leak in xmlBufAttrSerializeTxtContentNick Wellnhofer2017-06-071-5/+0
| | | | | | | | | | 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.
* Avoid an out of bound access when serializing malformed stringsCVE-2016-4483Daniel Veillard2016-05-231-4/+4
| | | | | | | | 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.
* When calling xmlNodeDump make sure we grow the buffer quicklyDaniel Veillard2013-02-111-0/+4
| | | | | Make sure the underlying new buffer allocated use a double-it scheme for the time of the dump.
* Big space and tab cleanupDaniel Veillard2012-09-111-23/+23
| | | | Remove all space before tabs and space and tabs at end of lines.
* Adding various checks on node type though the APIDaniel Veillard2012-08-091-0/+4
| | | | | Specifially checking against namespace nodes before accessing node pointers
* New saving functions using xmlBuf and conversionDaniel Veillard2012-07-231-53/+210
| | | | | | * 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
* fix a pair of possible out of array char referencesDaniel Veillard2012-01-221-2/+2
| | | | | When serializing char references back to an character string Reported by Abhishek Arya <inferno@chromium.org>
* Add xmlSaveOption XML_SAVE_WSNONSIGAdam Spragg2010-11-031-9/+83
| | | | | | | | 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
* Force _xmlSaveCtxt.format to be 0 or 1Adam Spragg2010-11-011-16/+16
| | | | | | * 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.
* Chasing dead assignments reported by clang-scanDaniel Veillard2009-09-071-1/+0
| | | | | | | | * 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)
* Wrong block opening in htmlNodeDumpOutputInternalDaniel Veillard2009-09-021-2/+2
| | | | | * xmlsave.c: Jim Meyering ran clang on libxml2 and this is one of the error found, misplaced curly brace
* new options to serialize as XML/HTML/XHTML and restore old entry pointDaniel Veillard2008-09-251-4/+23
| | | | | | | | * 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
* Borland C fix from Moritz Both regenerate, workaround a problem for bufferDaniel Veillard2008-09-011-82/+197
| | | | | | | | | | | | | | | | | | | * 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
* fix handling of empty CDATA nodes as reported and discussed around #514181Daniel Veillard2008-03-071-14/+18
| | | | | | | | | | | * 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
* fix to avoid a crash when dumping an attribute from an XHTML document,Daniel Veillard2007-10-101-0/+4
| | | | | | | | * 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
* fixed problem reported on bug #460415 DanielDaniel Veillard2007-07-261-5/+6
| | | | | | | * xmlsave.c: fixed problem reported on bug #460415 Daniel svn path=/trunk/; revision=3646
* Fixed typo in xmlCharEncFirstLine pointed out by Mark Rowe (bug #440159)William M. Brack2007-05-221-1/+0
| | | | | | | | | | | | * 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
* applied patch from Björn Wiberg to try to fix again the sillyDaniel Veillard2007-03-201-1/+3
| | | | | | | | * 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
* started to switch xmllint to use xmlSaveDoc to test #342556 fixed #342556Daniel Veillard2006-10-161-15/+77
| | | | | | | | * 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
* fixed a comment applied a patch from Michael Day to add a new functionDaniel Veillard2006-09-291-1/+1
| | | | | | | | * 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
* Add linefeeds to error messages allowing for consistant handling.Rob Richards2006-08-151-5/+5
| | | | | * HTMLtree.c xmlsave.c: Add linefeeds to error messages allowing for consistant handling.
* Removed the automatic generation of CDATA sections for the content of theKasimier T. Buchcik2006-07-131-1/+9
| | | | | | | | | * 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.
* applied patch from Geert Jansen to implement the save function to aDaniel Veillard2005-11-091-10/+33
| | | | | | | * 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
* prevent output of fragment tags when serializing XHTML.Rob Richards2005-10-211-0/+4
| | | | * xmlsave.c: prevent output of fragment tags when serializing XHTML.
* release of 2.6.22 updated doc and rebuild. added XML_SAVE_NO_XHTMLLIBXML2_2_6_22Daniel Veillard2005-09-121-7/+9
| | | | | | | | | * 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
* applied second patch from David Madore to be less intrusive when handlingDaniel Veillard2005-09-121-11/+12
| | | | | | | * 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