1
0
mirror of https://github.com/GNOME/libxml2.git synced 2025-05-12 22:53:36 +08:00

708 Commits

Author SHA1 Message Date
Daniel Veillard
768eb3b82d Convert XML parser to the new input buffers
The main changes are when the internal of the buffers structure
were adressed directly, we now use routines coming from buf.h
The routine xmlParserInputRead() which wasn't used anywhere is
deprecated too.
2012-07-23 14:24:26 +08:00
Daniel Veillard
4629ee02ac Do not fetch external parsed entities
Unless explicietely asked for when validating or replacing entities
with their value. Problem pointed out by Tom Lane <tgl@redhat.com>

* parser.c: do not load external parsed entities unless needed
* test/errors/extparsedent.xml result/errors/extparsedent.xml*:
  add a regression test to avoid change of the behaviour in the future
2012-07-23 14:15:40 +08:00
Daniel Veillard
459eeb9dc7 Fix parser local buffers size problems 2012-07-18 17:54:04 +08:00
Daniel Veillard
379ebc1d77 Cleanup on randomization
tsan reported that rand() is not thread safe, so create
a thread safe wrapper, use rand_r() if available.
Consolidate the function, initialization and cleanup in
dict.c and make sure it is initialized in xmlInitParser()
2012-05-18 15:41:31 +08:00
Daniel Veillard
ed35d3d7c3 Fix an uninitialized variable use
When compiled without SAX1 support
2012-05-11 10:52:27 +08:00
Lin Yi-Li
24464be639 Avoid memory leak if xmlParserInputBufferCreateIO fails
For https://bugzilla.gnome.org/show_bug.cgi?id=643949

In case of error on an IO creation input the given context
is terminated with the given close function, except if the
error happened in xmlParserInputBufferCreateIO. This can
lead to a resource leak which is fixed by this patch.
2012-05-10 16:14:55 +08:00
Bryan Henderson
8658d27d4f wrong message for double hyphen in comment XML error
The error message when you have a double hyphen in a comment is "comment
not terminated" and should be "double hyphen in comment".
2012-05-08 16:39:05 +08:00
Daniel Veillard
288bb6274f Fix an error in comment
nsWarn handler is not about parser fatal errors
2012-05-07 15:01:29 +08:00
Daniel Veillard
4aa68abb1c Try to fix a problem with entities in SAX mode
this is a problem which hit the raptor code and that small
patch should be a reliable workaround
2012-04-02 17:50:54 +08:00
Anders F Bjorklund
eae5261779 add lzma compression support 2012-01-27 22:19:52 +08:00
Daniel Veillard
5bd3c06182 Fix an allocation error when copying entities 2011-12-16 18:53:35 +08:00
Chris Evans
77404b8b69 Make sure the parser returns when getting a Stop order
patch backported from chromiun bug fixes, assuming author is Chris
2011-12-14 16:18:25 +08:00
Xia Xinfeng
5825ebb26a Fix some potential problems on reallocation failures(parser.c)
This problem is the same as d7958b21e7f8c447a26bb2436f08402b2c308be4.
The operation "ctxt->nameMax * = 2;" should be placed after the function
call of xmlRealloc().
2011-11-11 13:43:27 +08:00
Daniel Veillard
4c4653e587 Add exception for new W3C PI xml-model 2011-06-05 11:29:29 +08:00
Daniel Veillard
c62efc847c Add options to ignore the internal encoding
For both XML and HTML, the document can provide an encoding
either in XMLDecl in XML, or as a meta element in HTML head.
This adds options to ignore those encodings if the encoding
is known in advace for example if the content had been converted
before being passed to the parser.

* parser.c include/libxml/parser.h: add XML_PARSE_IGNORE_ENC option
  for XML parsing
* include/libxml/HTMLparser.h HTMLparser.c: adds the
  HTML_PARSE_IGNORE_ENC for HTML parsing
* HTMLtree.c: fix the handling of saving when an unknown encoding is
  defined in meta document header
* xmllint.c: add a --noenc option to activate the new parser options
2011-05-26 11:47:37 +08:00
Rob Richards
c794eb5bb0 Fix memory corruption
when xmlParseBalancedChunkMemoryInternal is called from xmlParseBalancedChunk
2011-02-18 12:17:17 -05:00
Giuseppe Iuculano
48f7dcb724 480323 add code to plug in ICU converters by default
This is not configured in by default but after some serious massaging
incorporate that patch from Chromium/Chrome.
2010-11-04 17:42:42 +01:00
Daniel Veillard
60587d6ebd 606592 update language ID parser to RFC 5646
Mostly except we keep support for some older constructs and
don't implement extension or privateuse. It's messy because
it's used mostly by XSD datatype which itself reference RFC 3066
and suggests a lexical space completely different from what
5646 defines.
2010-11-04 15:16:27 +01:00
Nikolay Sivov
e6ad10a5b9 Cleanup encoding pointer comparison
* parser.c: Compare encoding pointer with a NULL instead of
  xmlCharEncoding enum value 0 then casted to char * !
2010-11-01 11:35:14 +01:00
Mike Hommey
e6f05099e8 Fix a potential segfault due to weak symbols on pthreads
In xmlInitParser, both __xmlGlobalInitMutexLock and xmlInitGlobals are
called before xmlInitThreads, and both use pthread symbols.
__xmlGlobalInitMutexLock does so directly, without checking if the symbol
exists, and xmlInitGlobals calls xmlNewMutex, which correctly depends on
libxml_is_threaded... except libxml_is_threaded is still -1 by then...
And again, when releasing the global mutex in __xmlGlobalInitMutexUnlock,
the pthread function is called directly.

The patch changes the initialization order and make sure the functions
are available before calling them
2010-10-15 19:50:03 +02:00
Raul Hudea
ba9716a197 ChunkParser: Incorrect decoding of small xml files
if encoding was autodetected, in xmlParseChunk, if initial size is 86 (a
chunk in UTF-16 encoding), the code that tries to read only the first line
will set the size to 90, which eventually leads to a memmove of 90 bytes
(in xmlBufferAdd) which will copy extra random memory bytes, which will
make the parser to fail because of these extra bytes.
2010-03-15 10:13:29 +01:00
Daniel Veillard
47cd14e850 Fix encoding selection for xmlParseInNodeContext
* parser.c: use the encoding from the document to parse the chunk
2010-02-04 18:49:01 +01:00
Daniel Veillard
59df7834a2 608773 add a missing check in xmlGROW
* parser.c: check that the input buffer is non null before dereferencing it
2010-02-02 10:24:01 +01:00
Daniel Veillard
e20fb5a72c Fix xmlParseInNodeContext for HTML content
xmlParseInNodeContext notices that the enclosing document is
an HTML document, so invoke the HTML parser for that fragment, and
the HTML parser finding a "<p>hello world!</p>" document automatically
augment it with defaulted <html> and <body>. This defaulting should
be turned off in the HTML parser for this to work, but there is no
such HTML parser option. There is an htmlOmittedDefaultValue global
variable that you could use, but really we should not rely on global
variable for processing options anymore, best is to add an
HTML_PARSE_NOIMPLIED.
* include/libxml/HTMLparser.h: add the HTML_PARSE_NOIMPLIED parser flag
* HTMLparser.c: do add implied element if HTML_PARSE_NOIMPLIED is set
* parser.c: add HTML_PARSE_NOIMPLIED to options for xmlParseInNodeContext
  on HTML documents
2010-01-29 20:47:08 +01:00
Nikolay Sivov
7304683335 Correct variable type to unsigned
* parser.c: fix len sign in xmlParseChunk()
2010-01-19 15:38:05 +01:00
Daniel Veillard
9d3d141c41 Fix a parsing problem with little data at startup
* parser.c: inkscape extension loader (and possibly others) feed
  data to the parser very slowly, 0 at start, 4 bytes on first GROW
  and this broke after the fix for
  https://bugzilla.gnome.org/show_bug.cgi?id=566012
  http://git.gnome.org/cgit/libxml2/commit/?id=7e385bd4e28a0cc12b6b26ed178c620e3c3ab8d8
  leading to another bug
  https://bugzilla.redhat.com/show_bug.cgi?id=523002
  this detects the situation and GROW when needed for proper processing.
2009-09-15 18:41:30 +02: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
d44b936499 A few more safety cleanup raised by scan
* SAX2.c encoding.c parser.c xmlschemas.c: a few more safety checks
* relaxng.c: remove an unused intitialization
2009-09-07 12:15:08 +02:00
Daniel Veillard
76d364583e Fixing assorted potential problems raised by scan
* encoding.c parser.c relaxng.c runsuite.c tree.c xmlreader.c
  xmlschemas.c: nothing really serious but better safe than sorry
2009-09-07 11:19:33 +02:00
Daniel Veillard
154956103d Potential uninitialized arguments raised by scan
* parser.c: ctxt->sax2 is not supposed to change suring parsing
  but better safe than sorry and initialize prefix and URI used in
  SAX2 callbacks.
2009-09-05 15:04:41 +02:00
Daniel Veillard
13cee4e37b Fix a bunch of scan 'dead increments' and cleanup
* HTMLparser.c c14n.c debugXML.c entities.c nanohttp.c parser.c
  testC14N.c uri.c xmlcatalog.c xmllint.c xmlregexp.c xpath.c:
  fix unused variables, or unneeded increments as well as a couple
  of space issues
* runtest.c: check for NULL before calling unlink()
2009-09-05 14:52:55 +02:00
Daniel Veillard
74eaec1496 502960 provide namespace stack when parsing entity
* parser.c: copy the entity stack
* SAX2.c: fix the warning message for default entities
2009-08-26 15:57:20 +02:00
Daniel Veillard
a6c76a26ca 566012 part 2 fix regresion tests and push mode
* test/utf16bebom.xml: regression test showed that this test case was
  broken but previous behaviour would not detect it !
* parser.c: fix 566012 for the push mode of the parser, tricky !
* test/ebcdic_566012.xml result//ebcdic_566012.xml*: add the test to the
  regression suite
2009-08-26 14:37:00 +02:00
Daniel Veillard
7e385bd4e2 566012 autodetected encoding and encoding conflict
* encoding.c parser.c parserInternals.c: when we autodetect an encoding
  but it's actually not completely compatible with the one declared
  great care must be taken to not convert more than just the first line.
  Led to some refactoring, more private functions and a bit of cleanup.
2009-08-26 11:38:49 +02:00
Daniel Veillard
283d50279d 587663 Incorrect Attribute-Value Normalization
* parser.c: when replacing entities and that the entity is CDATA and
  reference entities then white space character in replacement text
  need to be replaced by 0x20
* result/noent/att10: correct the output of the associated regression
  test
2009-08-25 17:18:39 +02:00
Daniel Veillard
852505b38f 583439 missing line numbers in push mode
* parser.c: use the line number stored in the node itself if present
  for end of tag line error reports
2009-08-23 15:44:48 +02:00
Daniel Veillard
53c32edfa5 Rebuilt the API and regenerated docs 2009-08-21 15:20:55 +02:00
Daniel Veillard
8ed1072c2d Add symbol versioning to libxml2 shared libs
* libxml2.syms: the symbols with history, going back to 2.4.30
* Makefile.am configure.in: linking flags detection and use
* parser.c tree.c valid.c xpointer.c: various cleanup of functions
  which could be made static or simply discarded, not that many
2009-08-20 19:17:36 +02:00
Daniel Veillard
f39eafaa90 Make xmlRecoverDoc const (Martin Trappel)
* include/libxml/parser.h parser.c: just make the parameter a const
2009-08-20 19:15:08 +02:00
Daniel Veillard
489f9671e7 Fix a couple of problems in the parser
* parser.c: a couple of nasty bugs CVE-2009-2414 and CVE-2009-2416
2009-08-10 16:49:30 +02:00
Daniel Veillard
48247b4fc4 Fix a regression in streaming entities support
* parser.c: fix a regression in entity parsing when using the reader
  introduced because we were not reusing _private on entities parsing
  context
2009-07-10 16:12:46 +02:00
Daniel Veillard
44af232c83 Fix ChangeLog merge conflict 2009-07-09 09:02:11 +02:00
Daniel Veillard
ab2a763db8 A bit of cleanups
* tree.c: avoid calling xmlAddID with NULL values
* parser.c: add a few xmlInitParser in some entry points
2009-07-09 08:45:03 +02: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
7dd7080ad7 * parser.c threads.c: change the threading initialization sequence
as suggested by Igor Novoseltsev to avoid crash if xmlInitParser()
  is called from a thread which is not the main one, should fix
  #584605
daniel
2009-06-04 11:08:39 +02:00
Rob Richards
2c8c772d68 * parser.c: do not set error code in xmlNsWarn 2009-04-29 10:09:05 -04:00
Rob Richards
9c0aa472d9 use options from current parser context when creating an entity parser
* parser.c: use options from current parser context when creating 
  an entity parser context

svn path=/trunk/; revision=3825
2009-03-26 18:10:19 +00:00
Daniel Veillard
c656146328 hide the nbParse* variables used for debugging as pointed by Mike Hommey
* parser.c: hide the nbParse* variables used for debugging
  as pointed by Mike Hommey
daniel

svn path=/trunk/; revision=3823
2009-03-25 10:22:31 +00:00
Daniel Veillard
01101204f6 more warnings about xmlCleanupThreads and xmlCleanupParser to avoid
* threads.c parser.c: more warnings about xmlCleanupThreads and
  xmlCleanupParser to avoid troubles like #571409
daniel

svn path=/trunk/; revision=3818
2009-02-21 09:22:04 +00:00