1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-01-15 23:24:06 +03:00

5674 Commits

Author SHA1 Message Date
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 b2dc5675e94aa6b5557ba63f7d66b0f08dd17e4d
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
d7cb33cf44aa688f24215c9cd398c1a26f0d25ff 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
Nick Wellnhofer
1406b20fe9 encoding: Allocate default handlers statically 2022-11-24 19:21:01 +01:00
Sam James
278e7874e6 libxml.m4: fix -Wstrict-prototypes
Signed-off-by: Sam James <sam@gentoo.org>
2022-11-23 11:58:14 +00:00
Chun-wei Fan
707ade225c Visual Studio builds: Allow silencing deprecation warnings
Define XML_IGNORE_DEPRECATION_WARNINGS and the corresponding XML_POP_WARNINGS
for Visual Studio, and consequently define XML_IGNORE_FPTR_CAST_WARNINGS so
that we do not get a compiler warning on Visual Studio by doing a
__pragma(warning(pop)) without a corresponding __pragma(warning(push)).

Also correct the documentation a bit for XML_POP_WARNINGS.
2022-11-23 11:04:38 +08:00
Chun-wei Fan
b9590d5d81 Visual Studio: Define XML_DEPRECATED
We can mark APIs as deprecated using __declspec(deprecated) with Visual Studio
2005 and later, so add a definition of that so that we can help users avoid
using deprecated APIs when using Visual Studio as well.

For the existing GCC definition, check whether we are on GCC 3.1+ before
enabling the definition.
2022-11-23 10:41:08 +08:00
Nick Wellnhofer
b1f9c19383 parser: Fix push parser with unterminated CDATA sections
Short-lived regression found by OSS-Fuzz.
2022-11-22 21:39:01 +01:00
Nick Wellnhofer
97c0a9cff7 tests: Fix use-after-free in Python tests
The nodeset must be freed before the document.

Fixes #443.
2022-11-22 17:01:39 +01:00
Nick Wellnhofer
550345057d Fix .editorconfig 2022-11-22 17:01:21 +01:00
Nick Wellnhofer
34a5a4a5e5 tests: Remove unneeded #includes 2022-11-22 16:03:05 +01:00
Nick Wellnhofer
701beb4ec7 xmllint: Include <io.h> on Windows 2022-11-22 16:03:05 +01:00
Nick Wellnhofer
b9689d1371 gitlab-ci: Make Test-Msvc exit if ctest fails 2022-11-22 16:03:05 +01:00
Nick Wellnhofer
138c897dbf gitlab-ci: Treat compiler warnings as errors on MSVC 2022-11-22 15:49:37 +01:00
Nick Wellnhofer
d725addd92 warnings: Work around MSVC bug
MSVC apparently complains when passing a `const char **` to memset.
Unlike `const char *const *`, this isn't a pointer to const memory.
2022-11-22 15:49:27 +01:00
Chun-wei Fan
cfbe68e468 sources: Silence C4013 warnings on Visual Studio
The read(), close(), open(), lseek() functions are found in io.h on Visual
Studio, which does not ship unistd.h, so include io.h on Windows if unistd.h
is not found.

C4013 (aka implicit declaration of ...) warnings can often ring alarm bells.
2022-11-22 15:20:53 +08:00
Nick Wellnhofer
0e193f0d61 parser: Remove dangerous check in xmlParseCharData
If this check succeeds, xmlParseCharData could be called over and over
again without making progress, resulting in an infinite loop.

It's only important to check for XML_PARSER_EOF which is done later.

Related to #441.
2022-11-21 22:09:19 +01:00