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

4134 Commits

Author SHA1 Message Date
Alexey Neyman
48da90bc4a Python binding for xmlRegisterInputCallback
It is possible to make xmlIO handle any protocol by means of
xmlRegisterInputCallback(). However, that function is currently only
available in C API. So, the natural solution seems to be implementing Python
bindings for the xmlRegisterInputCallback.

* python/generator.py: skip xmlPopInputCallbacks
* python/libxml.c python/libxml.py python/libxml_wrap.h: implement the
  wrappers
* python/tests/input_callback.py python/tests/Makefile.am: also add a test case
2013-02-25 15:54:25 +08:00
Alexey Neyman
e32ceb93f4 Python bindings: DOM casts everything to xmlNode
I noticed another issue with Python bindings of libxml: the access methods do
not cast the pointers to specific classes such as xmlDtd, xmlEntityDecl, etc.
For example, with the following document:

<?xml version="1.0"?>
<!DOCTYPE root [<!ELEMENT root EMPTY>]>
<root/>

the following script:

import libxml2
doc = libxml2.readFile("c.xml", None, libxml2.XML_PARSE_DTDLOAD)
print repr(doc.children)

prints:

<xmlNode (root) object at 0xb74963ec>

With properly cast nodes, it outputs the following:

<xmlDtd (root) object at 0xb746352c>

The latter object (xmlDtd) enables one to use DTD-specific methods such as
debugDumpDTD(), copyDTD(), and so on.
2013-02-21 16:00:03 +08:00
Daniel Veillard
23f05e0c33 Detect excessive entities expansion upon replacement
If entities expansion in the XML parser is asked for,
it is possble to craft relatively small input document leading
to excessive on-the-fly content generation.
This patch accounts for those replacement and stop parsing
after a given threshold. it can be bypassed as usual with the
HUGE parser option.
2013-02-19 10:21:49 +08:00
Daniel Veillard
bf058dce13 Fix the flushing out of raw buffers on encoding conversions
https://bugzilla.gnome.org/show_bug.cgi?id=692915

the new set of converting functions tried to limit the encoding
conversion of the raw buffer to the consumption one to work in
a more progressive fashion. Unfortunately this was bad for
performances and led to errors on progressive parsing when
a very large chunk was close to the end of the document. Fix
the new internal function and switch back to the old way of
converting. Fix another bug in the process.
2013-02-13 18:19:42 +08:00
Daniel Veillard
de0cc20c29 Fix some buffer conversion issues
https://bugzilla.gnome.org/show_bug.cgi?id=690202

Buffer overflow errors originating from xmlBufGetInputBase in 2.9.0
The pointers from the context input were not properly reset after
that call which can do reallocations.
2013-02-12 16:55:34 +08:00
Mark Salter
60adeea933 Fix rpmbuild --nocheck
if the %check section was omitted some of the file needed for
packaging would not be generated, move the generation to the
proper place.
2013-02-11 12:45:56 +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
2af19f985b Cleanup of a duplicate test
in an and expression, pointed by Thomas Jarosch <thomas.jarosch@intra2net.com>
Daniel
2013-01-28 17:44:53 +01:00
Daniel Veillard
eea38159be Cleanup on duplicate test expressions
As pointed out by Thomas Jarosch <thomas.jarosch@intra2net.com>

Daniel
2013-01-28 16:55:30 +01:00
Patrick Gansterer
9c8eaabe83 Fix compiler warning after 153cf15905
Add missing cast for xmlNop to silence a compiler warning.
2013-01-04 19:48:55 +08:00
Dan Winship
cf8f0424db Fix an error in the progressive DTD parsing code
For https://bugzilla.gnome.org/show_bug.cgi?id=689958
We were looking for the wrong character in the input stream
2012-12-21 11:13:31 +08:00
Daniel Veillard
e4d16d7909 xmllint should not load DTD by default when using the reader 2012-12-21 10:58:14 +08:00
Daniel Richard
a0571ebeac Fix for win32/configure.js and WITH_THREAD_ALLOC
Building git master gives me the following error on Windows; this patch
fixes it:

	icl /EP /nologo /I..\include /D "NOLIBTOOL" /D "_REENTRANT"
libxml2.def.
src > int.msvc\libxml2.def
libxml2.def.src
Z:\...\libxml2-git8123c4f6_debug\win32\../include/libxml/xmlversion.h(105):
error: unrecognized token
  #if @WITH_THREAD_ALLOC@
      ^
Z:\...\libxml2-git8123c4f6_debug\win32\../include/libxml/xmlversion.h(105):
error: expected an expression
  #if @WITH_THREAD_ALLOC@
      ^
Z:\...\libxml2-git8123c4f6_debug\win32\../include/libxml/xmlversion.h(105):
error: unrecognized token
  #if @WITH_THREAD_ALLOC@
                        ^
NMAKE : fatal error U1077: 'icl' : return code '0x2'
Stop.
2012-12-12 17:16:00 +08:00
Petr Sumbera
6f49c73b53 Try IBM-037 when looking for EBCDIC handlers
http://en.wikipedia.org/wiki/EBCDIC_037
as it is another variat of EBCDIC
2012-12-12 15:41:30 +08:00
Daniel Veillard
8123c4f692 Fix Broken multi-arch support in xml2-config
partial revert of 87b4d6f610
coming from Fedora/RHEL/... but breaking other distros
as pointed out by Daniel Richard
2012-11-08 16:24:07 +08:00
Michael Wood
fb27e2cd20 Fix spelling of "length". 2012-10-30 10:18:49 +08:00
Tim Starling
0ad948ede2 Define LIBXML_THREAD_ALLOC_ENABLED via xmlversion.h
Otherwise, direct calls to xmlFree() etc. from the application will
use a different set of allocation functions to what was used to allocate
the memory internally.
2012-10-29 14:05:02 +08:00
Daniel Veillard
6a36fbe3b3 Fix potential out of bound access 2012-10-29 10:39:55 +08:00
Daniel Veillard
4ea74a440d Fix a portability issue for GCC < 3.4.0 2012-10-29 10:27:18 +08:00
Daniel Veillard
153cf15905 Fix large parse of file from memory
https://bugzilla.redhat.com/show_bug.cgi?id=862969
The new code trying to detect excessive input lookup would
just get wrong sometimes in the case of very large file parsed
directly from memory.
2012-10-26 13:50:47 +08:00
Daniel Veillard
711b15d545 Fix a bug in the nsclean option of the parser
Raised as a side effect of:
https://bugzilla.gnome.org/show_bug.cgi?id=663844
2012-10-25 19:23:26 +08:00
Daniel Veillard
a7982ce272 Adding streaming validation to runtest checks 2012-10-25 15:39:39 +08:00
Daniel Veillard
1abd221be5 Add a --pushsmall option to xmllint
To test the push parser with small chunks or 10 bytes
2012-10-25 15:37:50 +08:00
Daniel Veillard
6c91aa384f Fix a regression in 2.9.0 breaking validation while streaming
https://bugzilla.gnome.org/show_bug.cgi?id=684774
with help from Kjell Ahlstedt <kjell.ahlstedt@bredband.net>
2012-10-25 15:33:59 +08:00
Daniel Veillard
87b4d6f610 Spec cleanups and a fix for multiarch support 2012-10-11 14:44:22 +08:00
Daniel Veillard
7457c67fb9 Remove potential calls to exit() 2012-10-11 12:25:51 +08:00
Daniel Veillard
713434d230 Silence a clang warning
as reported by Hans Wennborg <hans@chromium.org>
2012-09-26 10:21:06 +08:00
Daniel Veillard
7e86eb5d4b Cleanup the Copyright to be pure MIT Licence wording 2012-09-20 21:46:19 +08:00
Daniel Richard
bbe194518f Windows build fixes
Building 2.9.0 on MSVC7.1 was failing

This is because HAVE_CONFIG_H is not #defined
The patch addresses the above, adds testrecurse.exe and the
standard "make check" suite of tests to the MSVC makefile, and also
fixes the following (MSVC7.1) warnings:
buf.c(674) : warning C4028: formal parameter 1 different from
declaration
libxml2\timsort.h(71) : warning C4028: formal parameter 1 different from
declaration
2012-09-18 11:15:06 +08:00
Friedrich Haubensak
3f6cfbd1d3 Fix a thread portability problem
cannot compile libxml2-2.9.0 using studio 12.1 compiler on solaris 10

I.M.O. structure initializer (as PTHREAD_ONCE_INIT) cannot be used in
a structure assignment anyway
2012-09-15 17:21:23 +08:00
Wouter Van Rooy
e7715a5963 rand_seed should be static in dict.c
For https://bugzilla.gnome.org/show_bug.cgi?id=683933
rand_seed should be a static variable in dict.c

We ran into a problem with another library that exports rand_seed as a
function. Combined with 2.7.8 this was not a problem but later versions
have this problem.
2012-09-14 14:39:42 +08:00
Jan Pokorný
81d7a8245c Fix typos in parser comments
Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
2012-09-13 22:40:28 +08:00
Daniel Veillard
5d04ad11a8 Downgrade autoconf requirement to 2.63
It was automatically bumped to 2.68 and that's not needed
2012-09-11 17:17:15 +08:00
Daniel Veillard
38bbd3412d Release of libxml2-2.9.0
* libxml.spec.in: update
* doc/*: updated and regenerated
* libxml2.syms testapi.c: regenerated
2012-09-11 15:00:08 +08:00
Daniel Veillard
7651606f31 Various cleanups to avoid compiler warnings 2012-09-11 14:02:08 +08:00
Daniel Veillard
742a0bbbcc Keep libxml2.syms when running "make distclean" 2012-09-11 13:37:30 +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
e00778b492 Followup to LibXML2 docs/examples cleanup patch 2012-09-08 21:09:26 +08:00
Daniel Veillard
f933c89813 Keep non-significant blanks node in HTML parser
For https://bugzilla.gnome.org/show_bug.cgi?id=681822

Regardless if the option HTML_PARSE_NOBLANKS is set or not, blank nodes
are removed from a HTML document, for example:

<html>
  <head>
    <title>This is a test.</title>
  </head>
  <body>
    <p>This is a test.</p>
  </body>
</html>

is read as:

<html><head><title>This is a test.</title></head><body>
    <p>This is a test.</p>
  </body></html>

This changes the default behaviour but the old behaviour is available
as expected when using the parser flag HTML_PARSE_NOBLANKS

Based on original patch from Igor Ignatyuk <igor_ignatiouk@hotmail.com>

* HTMLparser.c: change various places in the parser where ignorable_space
  SAX callback was called without checking for the parser flag preference
* xmllint.c: make sure we use the new flag even for HTML parsing
* result/HTML/*: this modifies the output of a number of tests
2012-09-07 19:32:12 +08:00
Daniel Richard
878ec9db9d Second round of cleanups for LibXML2 docs/examples
configure.am:

* Explicitly disallow --enable-rebuild-docs when builddir != srcdir, per
   what you said about needing to build docs with an in-source build

doc/Makefile.am:

* Ensure that xmlversion.h is in the source tree before running
   apibuild.py, to avoid generating an incomplete libxml2-api.xml

* Update the .PHONY target (forgot to do this earlier)

doc/devhelp/Makefile.am:

* Wrap the doc-generating rule in an "if REBUILD_DOCS" conditional so it
   doesn't cause trouble for regular users

* Added a handy-dandy "rebuild" target

doc/examples/index.py:

* NOTE: You need to run this script to regenerate the files it creates,
   and then commit the newly-updated files! The generated files currently
   in git master (e.g. doc/examples/Makefile.am) are out of date even
   before this patch!

* index.html really needs to be in EXTRA_DIST

* Wrap the doc-generating rules in an "if REBUILD_DOCS" conditional,
   because they shouldn't be active otherwise
2012-09-07 14:52:17 +08:00
Daniel Veillard
47881284ae Add a forbidden variable error number and message to XPath
Related to https://bugzilla.gnome.org/show_bug.cgi?id=680938

When the XML_XPATH_NOVAR flags is being used it means that
variables are forbidden, not that they are missing
2012-09-07 14:24:50 +08:00
Michael Stahl
55b899a23a Support long path names on WNT
so we've got this patch to libxml2 2.7.6 in the LibreOffice code base,
inherited from OOo.  it fixes a definite problem, which is that Windows
has a rather low maximum path length restriction, and there is a special
trick on NT whereby path names can be prefixed with "\\?\", in which
case the maximum length is 32k, which ought to be sufficient even for
bloated office suites :)

I'll attach the patch to the xmlCanonicPath function.  note that i
didn't write this and am by no means an expert on either Microsoftean
platforms or libxml so maybe it's not the best way to do it.
2012-09-07 12:19:25 +08:00
Daniel Veillard
1bd45d1309 Change the XPath code to percolate allocation errors
looping 1000 time on an error stating that a nodeset has
grown out of control is useless, make sure we percolate
error up to the various loops and break when errors occurs
2012-09-05 15:35:19 +08:00
Daniel Veillard
7d4c529a33 Improve HTML escaping of attribute on output
Handle special cases of &{...} constructs as hinted in the spec
  http://www.w3.org/TR/html401/appendix/notes.html#h-B.7.1
and special values as comment <!-- ... --> used for server side includes
This is limited to attribute values in HTML content.
2012-09-05 12:11:43 +08:00
Daniel Veillard
857104cd49 Remove all .cvsignore as they are not used anymore
For https://bugzilla.gnome.org/show_bug.cgi?id=682985
suggested by Adrian Bunk <bunk@stusta.de>
2012-09-04 14:25:23 +08:00
Daniel Veillard
7a2215dbcd Fix reuse of xmlInitParser
While xmlCleanupParser() should not be used unless complete control
is insured over the programe making sure libxml2 is not in use anywhere
It should still be usable, and allow a sequence of
    xmlInitParser();
    xmlCleanupParser();
calls if needed, the problem is that the thread key wasn't reallocated
on subsequent xmlinitParser() calls leading to corruption of pthread
keys used by the program.

* threads.c: make sure xmlCleanupParser() reset the pthread_once()
             global variable driving thread key allocation.
2012-09-04 12:05:17 +08:00
Daniel Veillard
510e7583f4 Fix a Timsort function helper comment 2012-09-04 11:50:36 +08:00
Daniel Veillard
28f5e1a2d6 Fix potential crash on entities errors
Related to https://bugs.launchpad.net/lxml/+bug/502959

Basically the core of the issue is that if an entity references another
entity, then in case we are replacing entities content, we should always
do so by copying the referenced content as long as the reference is
done within the entity. Otherwise, if for some reason there is a later
parsing error that entity content may be freed.

Complex scenario exposed by command:
thinkpad:~/XML/diveintopython-5.4/xml -> valgrind --db-attach=yes
../../xmllint --loaddtd --noout --noent diveintopython.xml

  Document references &a;
  a references &b;
  we references b content directly in by linking in the a content
  a has an error further down
  we free a, freeing the chunk from b
  Document references &b; after &a;
  we try to copy b content, but it was freed already => segfault

* parser.c: never reference directly entity content without copying if
  we aren't in the document main entity
2012-09-04 11:18:39 +08:00
Christian Weisgerber
3b6d7b9aee xml2-config.1 markup error
There is a spurious ".l" in the xml2-config.1 man page.  This line can
simply be removed.

$ mandoc -Tlint -Werror xml2-config.1
xml2-config.1:12:2: ERROR: skipping unknown macro: .l
2012-08-28 23:40:56 +08:00