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

5838 Commits

Author SHA1 Message Date
Nick Wellnhofer
ae0c9cfa05 uri: Fix handling of port numbers
Allow port number without host, real fix for #71.

Also compare port numbers in xmlBuildRelativeURI.

Fix handling of port numbers in xmlUriEscape.
2022-12-13 01:43:49 +01:00
Nick Wellnhofer
8ed40c621b Revert "uri: Allow port without host"
This reverts commit f30adb54f5.

Fixes #460.
2022-12-13 00:51:33 +01:00
Nick Wellnhofer
a77e32736c xmlmemory.c: Remove xmlMemContentShow
This debug function was always unsafe and hard-coded pointer sizes to
32 bits. Instead of attempting a fix, remove it completely. These days,
tools like ASan are much better to debug memory issues.

Fixes #214.
2022-12-08 19:45:40 +01:00
Nick Wellnhofer
25ea7b6aa0 testapi.c: Initialize catalog early
Avoid leak reports when testing --with-mem-debug.
2022-12-08 19:44:09 +01:00
Nick Wellnhofer
eaebf37fb6 gentest.py: Fix memory leak in API tests
Regressed in commit ff34ba3e.
2022-12-08 19:18:10 +01:00
Nick Wellnhofer
785cfcff49 doc/libxml2-api.xml: Regenerate 2022-12-08 19:18:09 +01:00
Nick Wellnhofer
0f54af7494 encoding.c: Fix for documentation generator
Top-level macro invocations throw off the documentation parser.
2022-12-08 18:40:58 +01:00
Lukáš Tyrychtr
85c6cacd67 catalog.c: Silence a cast warning on VS 2022
Fixes #457.
2022-12-08 13:34:03 +01:00
Nick Wellnhofer
93a01c46f1 libxml.h: Add comments and indentation 2022-12-08 04:39:03 +01:00
Nick Wellnhofer
92b8ffada8 libxml.h: Remove dubious definition of LIBXML_STATIC
This macro is supposed to be set by the build system.
2022-12-08 04:24:57 +01:00
Nick Wellnhofer
60d457be30 libxml.h: Don't include stdio.h 2022-12-08 04:24:57 +01:00
Nick Wellnhofer
924ed82735 libxml.h: Remove ancient LynxOS setup 2022-12-08 04:22:11 +01:00
Nick Wellnhofer
a6debffd7f xmlexports.h: Disable docs for internal macro XMLPUBLIC 2022-12-08 04:22:11 +01:00
Nick Wellnhofer
3b6cc47ab9 xmlexports.h: Remove LIBXML_FASTCALL optimization
This was an experimental and undocumented micro-optimization for
Windows which apparently required different calling conventions for
variable-argument functions, making it impossible to maintain without
domain knowledge.
2022-12-08 04:19:02 +01:00
Nick Wellnhofer
ce9baf94d5 Remove XMLCALL and XMLCDECL macros from public headers 2022-12-08 02:48:27 +01:00
Nick Wellnhofer
dd3569eaa5 Remove XMLDECL macro from .c files 2022-12-08 02:43:17 +01:00
Nick Wellnhofer
06b7a7e05b Update README.md
Mention official releases and Git repo prominently. Remove links to old
mailing list.
2022-12-08 00:54:13 +01:00
Nick Wellnhofer
b92768cd62 tests: Enable "runsuite" test
This enables some tests with testcases in

- test/xsdtest
- test/relaxng/OASIS/spectest.xml
- test/relaxng/testsuite.xml

The XML Schema Test Suite will also be run it was downloaded, see
xstc/Makefile.am. Gitlab CI should be updated to fetch these files.

There are 10 expected errors in the XSD test suite. This seems to be the
case since at least version 2.9.0 from 2012.
2022-12-08 00:24:53 +01:00
Ross Burton
4762c85668 Use python3 not python
As per https://peps.python.org/pep-0394/, the python binary can be one
of the following options:
- Python 2
- Python 3
- Not exist

All of the scripts in libxml2 use 'python', which may not exist.

As Python 2 reached EOL on the 1st January 2020, it's safe to move the
scripts to use python3 explicitly.
2022-12-07 13:21:12 +00:00
Ross Burton
ff49041c62 xstc/fixup-tests.py: port to Python 3 2022-12-07 13:21:12 +00:00
Ross Burton
7640362e76 xstc/fixup-tests.py: unify whitespace
The source contains a mix of tabs and spaces, so unify on spaces.
2022-12-07 13:20:53 +00:00
Ross Burton
d598d8af09 libxml.m4: deprecate AM_PATH_XML2, wrap PKG_CHECK_MODULES instead
pkg-config has been around for a very long time now, so deprecate the
hand-written libxml.m4 fragment providing AM_PATH_XML2 and simply
change it to a wrapper around PKG_CHECK_MODULES.
2022-12-06 18:17:49 +00:00
Ross Burton
0ac8c15eb4 python/tests/reader2: use absolute paths everywhere
The expected errors contain an relative path, but the messages from the
parser contain absolute paths.  However, due to the tests not actually
failing if there was an error this wasn't noticed.

Instead of putting relative paths in the expected messages use format()
to embed the correct absolute path.

Also use os.path.join() consistently when constructing paths to ensure
uniformly formatted paths.
2022-12-06 17:27:34 +00:00
Ross Burton
b9ba5e1d90 python/tests/reader2: always exit(1) if a test fails
Batch up the errors in the first parse tests and ensure that the last
tests exit with an error if they fail.

Also remove an unused import.
2022-12-06 17:25:34 +00:00
Ross Burton
21f2ce7112 testModule: exit if the module can't be opened
Instead of silently exiting with success when the module cannot be found,
emit a message and fail the test.
2022-12-06 17:24:37 +00:00
Ross Burton
b1b0df6e9b CI: disable modules in gcc:static build
When shared libraries are disabled we can't build loadable modules
either, so the testModule test can't work as the testdso.la target
doesn't build a module.
2022-12-06 17:23:12 +00:00
Ross Burton
3aaaf5cae6 CI: fix CI on MinGW builds
The XML test case tarball isn't actually compressed: the published URL
is a .tar and fetches of the .tar.gz redirect silently to the .tar,
which is then passed to gzip which refuses to decompress uncompressed
data.

Fetch the .tar as that is the documented URL, and remove the
decompression.
2022-12-06 17:16:39 +00:00
Nick Wellnhofer
76c6da4209 error: Make sure that error messages are valid UTF-8
This has caused issues with the Python bindings for a long time.

Should fix #64.
2022-12-04 23:34:19 +01:00
Alex Richardson
4b959ee168 Remove hacky heuristic from b2dc5675e9
Checking whether the context is close to the parent context by hardcoding
250 is not portable (I noticed tests were failing on Morello since the value
is 288 there due to pointers being 128 bits). Instead we should ensure
that the XML_VCTXT_USE_PCTXT flag is not set in cases where the user data
is not actually a parser context (or ideally add a separate field but that
would be an ABI break.

From what I can see in the source, the XML_VCTXT_USE_PCTXT is only set if
the userData field points to a valid context, and if this is not the case
the flag should be cleared when changing userData rather than relying on
the offset between the two. Looking at the history, I think
d7cb33cf44 fixed most of the need for this
workaround, but it looks like there are a few more locations that need
updating; This commit changes two more places to set/clear/copy the
XML_VCTXT_USE_PCTXT flag, so this heuristic should not be needed anymore.
I've also drop two = NULL assignment in xmllint since this is not needed
after a call to memset().

There was also an uninitialized vctxt.flags (and other fields) in
`xmlShellValidate()`, which I've fixed by adding a memset() call.
2022-12-01 15:31:25 +00:00
Alex Richardson
c715ded086 Avoid creating an out-of-bounds pointer by rewriting a check
Creating more than one-past-the-end pointers is undefined behaviour in C
and while this code is unlikely to be miscompiled, I discovered that an
out-of-bounds pointer is being created using UBSan on a CHERI-enabled
system.
2022-12-01 15:30:12 +00:00
Alex Richardson
c62c0d82cc Correctly relocate internal pointers after realloc()
Adding an offset to a deallocated pointer and assuming that it can be
dereferenced is undefined behaviour. When running libxml2 on CHERI-enabled
systems such as Arm Morello this results in the creation of an out-of-bounds
pointer that cannot be dereferenced and therefore crashes at runtime.

The effect of this UB is not just limited to architectures such as CHERI,
incorrect relocation of pointers after realloc can in fact cause
FORTIFY_SOURCE errors with recent GCC:
https://developers.redhat.com/articles/2022/09/17/gccs-new-fortification-level
2022-12-01 15:14:40 +00:00
Nick Wellnhofer
c7a9b85cbb html: Improve parsing of nested lists
Allow ul/ol as immediate children of ul/ol. This is more in line with
the HTML5 spec.

Fixes #447.
2022-11-30 17:11:33 +01:00
Nick Wellnhofer
ccb6d54409 Hide internal functions
These functions were never declared in public headers, so it should be
safe to hide them.

Fixes #139.
2022-11-27 02:20:53 +01:00
Nick Wellnhofer
82bd2c3736 python: Fix memory leak checks
xmlInitParser doesn't allocate memory anymore, so the checks can be
simplified.
2022-11-27 02:11:07 +01:00
Nick Wellnhofer
1966382b34 memory: Don't use locks in xmlMemUsed
The Python tests call xmlMemUsed after xmlCleanupParser which doesn't
work with statically allocated mutexes. This is only used for debugging,
so a lock isn't necessary.
2022-11-27 02:11:07 +01:00
Nick Wellnhofer
e414f82585 html: Fix htmlInitAutoClose documentation 2022-11-27 02:11:07 +01:00
Nick Wellnhofer
c16fd705bb xpath: Make init function private 2022-11-27 02:11:07 +01:00
Nick Wellnhofer
53ab38408d encoding: Make init function private 2022-11-27 02:11:07 +01:00
Nick Wellnhofer
3e9d5e4f7f encoding: Remove unused variable xmlDefaultCharEncodingHandler 2022-11-27 02:11:07 +01:00
Nick Wellnhofer
05c3a458aa tests: Check that xmlInitParser doesn't allocate memory 2022-11-27 02:11:07 +01:00
Nick Wellnhofer
78c0391bc7 parser: Register atexit handler in locked section 2022-11-25 15:12:56 +01:00
Nick Wellnhofer
71931233cd threads: Use __libc_single_threaded if available
Fixes #427
2022-11-25 15:12:56 +01:00
Nick Wellnhofer
c73d464afb threads: Deprecate some internal functions 2022-11-25 15:12:56 +01:00
Nick Wellnhofer
65d381f32c threads: Allocate mutexes statically 2022-11-25 15:12:56 +01:00
Nick Wellnhofer
9ef80ff1a9 memory: Remove xmlDictInitialized
Call xmlInitParser when creating dicts instead.
2022-11-25 15:02:04 +01:00
Nick Wellnhofer
ed053c50cf dict: Make init/cleanup functions private 2022-11-25 15:02:04 +01:00
Nick Wellnhofer
2e9aeecb4e memory: Remove xmlMemInitialized
Call xmlInitParser instead of xmlInitMemoryInternal.
2022-11-25 15:02:04 +01:00
Nick Wellnhofer
7010d8779b threads: Rework initialization
Make init/cleanup functions private. Merge xmlOnceInit into
xmlInitThreadsInternal.
2022-11-25 15:02:04 +01:00
Nick Wellnhofer
9dbf137455 parser: Make some module init/cleanup functions private 2022-11-25 15:02:04 +01:00
Nick Wellnhofer
cecd364dd2 parser: Don't call *DefaultSAXHandlerInit from xmlInitParser
Change the default handler definitions to match the result after calling
the initialization functions.

This makes sure that no thread-local variables are accessed when calling
xmlInitParser.
2022-11-25 15:02:04 +01:00