1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2024-12-24 21:33:51 +03:00
Commit Graph

73 Commits

Author SHA1 Message Date
Rosen Penev
2def7b4b28 clang-tidy: move assignments out of if
Found with bugprone-assignment-in-if-condition

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2024-06-20 21:11:44 -07:00
Nick Wellnhofer
faae3a91ce SAX2: Split out legacy SAX1 handling
Split xmlSAX2StartElement into two functions handling legacy SAX1 and
HTML.
2024-06-17 00:54:47 +02:00
Nick Wellnhofer
e314109ad1 save: Don't write directly to internal buffer
Make sure that OOM errors are reported.
2024-02-16 16:14:05 +01:00
Nick Wellnhofer
d2b55a7a02 writer: Implement xmlTextWriterClose
This function can be used to make sure that closing the output stream
succeeded.

Fixes #513.
2024-01-05 20:50:00 +01:00
Nick Wellnhofer
54c70ed57f parser: Improve error handling
Introduce xmlCtxtSetErrorHandler allowing to set a structured error for
a parser context. There already was the "serror" SAX handler but this
always receives the parser context as argument.

Start to use xmlRaiseMemoryError.

Remove useless arguments from memory error functions. Rename
xmlErrMemory to xmlCtxtErrMemory.

Remove a few calls to xmlGenericError.

Remove support for runtime entity debugging.
2023-12-21 02:46:27 +01:00
Nick Wellnhofer
9684e7a0f2 writer: Don't call SAX error handler directly 2023-12-11 22:13:06 +01:00
Nick Wellnhofer
5cffba8381 Rework va_copy fallback
va_copy is a macro, so it can be detected without a feature test.
Fallback to __va_copy or memcpy.
2023-11-28 15:59:40 +01:00
Nick Wellnhofer
a77f9ab84c globals: Don't include SAX2.h from globals.h 2023-09-20 22:06:49 +02:00
Nick Wellnhofer
550eaac605 writer: Add error check in xmlTextWriterEndDocument 2023-04-30 21:45:39 +02:00
Nick Wellnhofer
dd3569eaa5 Remove XMLDECL macro from .c files 2022-12-08 02:43:17 +01:00
Nick Wellnhofer
ad338ca737 Remove explicit integer casts
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.
2022-09-01 02:33:57 +02:00
Nick Wellnhofer
0f568c0b73 Consolidate private header files
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.
2022-08-26 02:11:56 +02:00
David Kilzer
21561e833a Mark more static data as const
Similar to 8f5710379, mark more static data structures with
`const` keyword.

Also fix placement of `const` in encoding.c.

Original patch by Sarah Wilkin.
2022-04-07 12:01:23 -07:00
Nick Wellnhofer
346c3a930c Remove elfgcchack.h
The same optimization can be enabled with -fno-semantic-interposition
since GCC 5. clang has always used this option by default.
2022-02-20 21:49:04 +01:00
Nick Wellnhofer
d8999b1da0 Fix error code in xmlTextWriterStartDocument
Return XML_ERR_UNSUPPORTED_ENCODING if no encoding handler could be
found.

Fixes bug #521808:
https://bugzilla.gnome.org/show_bug.cgi?id=521808

Resolves !53.
2019-10-14 17:06:36 +02:00
Jared Yanovich
2a350ee9b4 Large batch of typo fixes
Closes #109.
2019-09-30 18:04:38 +02:00
Nick Wellnhofer
86615e43bb Fix IO callback signatures 2017-11-09 17:47:47 +01:00
Nick Wellnhofer
4dd6d7a58e Fix list callback signatures
Make sure that all parameters and return values of list callback
functions exactly match the callback function type. This is required
to pass clang's Control Flow Integrity checks and to allow compilation
to asm.js with Emscripten.

Also change the `user` parameter type from `const void *` to `void *`.
2017-11-09 17:28:00 +01:00
J. Peter Mugaas
d2c329a9a4 Fix -Wimplicit-fallthrough warnings
Add "falls through" comments to quench implicit-fallthrough warnings
which are enabled by -Wextra under GCC 7.
2017-10-21 13:49:31 +02:00
David Kilzer
4472c3a5a5 Fix some format string warnings with possible format string vulnerability
For https://bugzilla.gnome.org/show_bug.cgi?id=761029

Decorate every method in libxml2 with the appropriate
LIBXML_ATTR_FORMAT(fmt,args) macro and add some cleanups
following the reports.
2016-05-23 15:01:07 +08:00
Daniel Veillard
c9ecf45d1b Fix xmlTextWriterWriteElement when a null content is given 2014-02-08 02:23:27 +08:00
Patrick Monnerat
0f7a26d844 Improve va_list portability
Support for va_list declared as an array (cannot be referenced
explicitly)
2013-12-12 15:04:43 +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
Csaba Raduly
429d3a0aae Allow to set the quoting character of an xmlWriter
It's otherwise impossible to set the quoting character of
attribute values of an xmlWriter.
2012-09-11 11:52:46 +08:00
Daniel Veillard
dbf5411b21 Convert the writer to new output buffer and save APIs
Only a handful of places had to be converted for xmlBuf and
the new saving entry point.
2012-07-23 14:24:27 +08:00
Rob Richards
798743a498 * parser.c: use options from current parser context when creating
a parser context within xmlParseCtxtExternalEntity
* xmlwriter.c: fix error message when unable to create output file
2009-06-19 13:54:25 -04:00
Daniel Veillard
bccae2d210 * c14n.c debugXML.c doc/examples/io2.c parser.c schematron.c
valid.c xmlschemas.c xmlwriter.c xpath.c: use %s to printf string
  patch by Christian Persch, fixes #581612
2009-06-04 11:22:45 +02:00
Daniel Veillard
cb0ae19174 cleanups and error reports when xmlTextWriterVSprintf fails, by Jinmei
* xmlwriter.c: cleanups and error reports when xmlTextWriterVSprintf
  fails, by Jinmei Tatuya
daniel

svn path=/trunk/; revision=3817
2009-02-20 08:40:55 +00:00
Daniel Veillard
eb0a0b2e31 remove a couple of leaks on errors reported by Jinmei Tatuya daniel
* xmlwriter.c: remove a couple of leaks on errors reported by
  Jinmei Tatuya
daniel

svn path=/trunk/; revision=3816
2009-02-20 08:19:53 +00:00
Rob Richards
5a7d8bdf71 xmlwriter.c: fix indenting in xmlTextWriterFullEndElement for bug# 554353.
svn path=/trunk/; revision=3805
2008-12-27 13:17:43 +00:00
Daniel Veillard
ccc476f177 patch from Alex Khesin fixing CDATA output after a text node. fixed the
* xmlwriter.c: patch from Alex Khesin fixing CDATA output after
  a text node.
* parser.c: fixed the comment for xmlParserCleanup
* globals.c: fixed indentation
Daniel

svn path=/trunk/; revision=3699
2008-03-04 13:19:49 +00:00
Daniel Veillard
3ff24115d2 applied patch from Alfred Mickautsch to flush the output at the end of
* xmlwriter.c: applied patch from Alfred Mickautsch to flush the
  output at the end of document.
Daniel

svn path=/trunk/; revision=3691
2008-02-13 10:17:41 +00:00
Daniel Veillard
7e26fb4b10 fix indentation in xmlTextWriterFullEndElement, as raised by Felipe Pena,
* xmlwriter.c: fix indentation in xmlTextWriterFullEndElement,
  as raised by Felipe Pena, should fix #508156
Daniel

svn path=/trunk/; revision=3668
2008-01-09 02:19:50 +00:00
Daniel Veillard
caa1951d59 patch from Dodji Seketeli to avoid a leak on repeated uses of
* xmlwriter.c: patch from Dodji Seketeli to avoid a leak on repeated
  uses of xmlTextWriterStartDocument()
Daniel

svn path=/trunk/; revision=3642
2007-07-04 15:42:46 +00:00
Rob Richards
b8769d6f24 fixed problem with namespace declaration being written more than once per
* xmlwriter.c: fixed problem with namespace declaration being 
  written more than once per element start tag

svn path=/trunk/; revision=3623
2007-06-08 08:50:47 +00:00
William M. Brack
c1099be5eb repositioned #include for libxml.h to avoid compilation error on some
* testAutomata.c, testRegexp.c, testThreads.c, testThreadsWin32.c,
  xmlwriter.c: repositioned #include for libxml.h to avoid
  compilation error on some architectures (bug #398277)

svn path=/trunk/; revision=3578
2007-01-31 18:38:56 +00:00
Rob Richards
9db68f0c14 Add a document to the xmlwriter structure and pass document when writing
* xmlwriter.c: Add a document to the xmlwriter structure and
  pass document when writing attribute content for encoding support.
2006-08-16 22:48:51 +00:00
Daniel Veillard
02c1f23297 patch from Jason Viers for line breaks after EndPI Daniel
* xmlwriter.c: patch from Jason Viers for line breaks after EndPI
Daniel
2006-04-27 08:10:25 +00:00
Rob Richards
ffe47feb27 Insert space between pubid and sysid when both passed to
* xmlwriter.c: Insert space between pubid and sysid when both
  passed to xmlTextWriterStartDTD and indenting not being used.
  Remove no longer used Mem callbacks.
2005-12-09 17:52:21 +00:00
Rob Richards
a44f234d3a function consolidation when writing to xmlBuffer. Return error condition
* xmlIO.c xmlwriter.c: function consolidation when writing to xmlBuffer.
  Return error condition not len if xmlwriter fails writing to buffer.
2005-11-09 18:03:45 +00:00
William M. Brack
f4caa5e698 fixed problem in xmlTextWriterVSprintf caused by misuse of vsnprintf added
* xmlwriter.c: fixed problem in xmlTextWriterVSprintf caused by
  misuse of vsnprintf
* configure.in, config.h.in: added a configuration check for
  va_copy and added a define for VA_COPY for xmlwriter.c fix
* parser.c: fixed problem with CRLF split between chunks (bug
  #319279) (fix provided by Brion Vibber)
2005-10-20 09:04:05 +00:00
Daniel Veillard
75e389d4e0 more cleanups based on sparse reports, added "make sparse" Daniel
* Makefile.am globals.c parserInternals.c xmlreader.c xmlunicode.c
  xmlwriter.c: more cleanups based on sparse reports, added
  "make sparse"
Daniel
2005-07-29 22:02:24 +00:00
Daniel Veillard
ffa3c74933 applied a patch from Marcus Boerger to fix problems with calling
* error.c globals.c parser.c runtest.c testHTML.c testSAX.c
  threads.c valid.c xmllint.c xmlreader.c xmlschemas.c xmlstring.c
  xmlwriter.c include/libxml/parser.h include/libxml/relaxng.h
  include/libxml/valid.h include/libxml/xmlIO.h
  include/libxml/xmlerror.h include/libxml/xmlexports.h
  include/libxml/xmlschemas.h: applied a patch from Marcus Boerger
  to fix problems with calling conventions on Windows this should
  fix #309757
Daniel
2005-07-21 13:24:09 +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
614fdc13b7 applied a patch from Rob Richards fixing a couple of bugs in the writer
* xmlwriter.c: applied a patch from Rob Richards fixing a couple
  of bugs in the writer
Daniel
2005-02-23 14:05:37 +00:00
Daniel Veillard
bd8fb0adc0 applied patch from Rob Richards to fix a problem with
* xmlwriter.c: applied patch from Rob Richards to fix a problem with
  xmlTextWriterStartAttributeNS
Daniel
2005-02-21 13:49:46 +00:00
Daniel Veillard
d0cf7f6eea integrated in "make tests" added -q option, and more conditional features
* Makefile.am gentest.py testapi.c: integrated in "make tests"
  added -q option, and more conditional features fixes
* catalog.c debugXML.c parser.c testThreads.c xmllint.c
  xmlschemastypes.c xmlwriter.cinclude/libxml/catalog.h
  include/libxml/debugXML.h: various compilation and conditional
  cleanups.
* doc/*: regenerated
Daniel
2004-11-09 16:17:02 +00:00
Daniel Veillard
a521d28751 better handling of conditional features more testing on parser contexts
* gentest.py testapi.c: better handling of conditional features
* HTMLparser.c SAX2.c parserInternals.c xmlwriter.c: more testing
  on parser contexts closed leaks, error messages
Daniel
2004-11-09 14:59:59 +00:00
Daniel Veillard
d5cc0f7f51 augmented types supported a number of new bug fixes and documentation
* gentest.py testapi.c: augmented types supported
* HTMLtree.c tree.c xmlreader.c xmlwriter.c: a number of new
  bug fixes and documentation updates.
Daniel
2004-11-06 19:24:28 +00:00
Daniel Veillard
dd6d300896 more fixes and extending the tests coverage adding a type init interface
* gentest.py testapi.c: more fixes and extending the tests coverage
* relaxng.c include/libxml/relaxng.h: adding a type init interface
* include/libxml/xmlerror.h parser.c xmlreader.c xmlwriter.c: more
  cleanups and bug fixes raised by the regression tests
Daniel
2004-11-03 14:20:29 +00:00