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

6343 Commits

Author SHA1 Message Date
Nick Wellnhofer
b8313b589f xpath: Rewrite substring-before and substring-after
Don't use buffers. Check malloc failures.
2023-12-28 16:47:45 +01:00
Nick Wellnhofer
3874e5d0ea tests: Remove unneeded error formatting code 2023-12-28 16:47:45 +01:00
Nick Wellnhofer
2a2fbe1e5b xinclude: Only set xml:base if necessary 2023-12-28 16:47:45 +01:00
Nick Wellnhofer
8a685a3dfc xinclude: Allow empty nodesets
There's no reason to treat an empty nodeset as error.
2023-12-28 16:47:45 +01:00
Nick Wellnhofer
f3fa34dcad parser: Fix general entity parsing
Clear namespace database.

Ignore non-fatal errors.
2023-12-28 16:47:41 +01:00
Nick Wellnhofer
ecfbcc8a52 parser: Rework general entity parsing
Don't create a new parser context but reuse the existing one.

This exposes bug #601 in a more obvious way.
2023-12-25 23:38:40 +01:00
Nick Wellnhofer
c2ef78f76e io: Fix close error handling
There's no way to report error codes from closing an output buffer yet.
2023-12-25 23:38:40 +01:00
Nick Wellnhofer
6d27c549e1 io: Fix read/write error handling
Handle short reads/writes from fd. Fix stdio error handling.
2023-12-25 23:38:40 +01:00
Nick Wellnhofer
0bef93bf24 io: More refactoring and unescaping fixes
Merge Windows wrappers into relevant functions.

Remove more unnecessary unescaping.

Merge *OpenW into *Open functions.

Use unbuffered IO for output.
2023-12-25 23:38:40 +01:00
Nick Wellnhofer
331dcd6200 error: Reenable full error reports to default handler
This should make console output include some information about nodes
again. Note that this extra information must be disabled if a custom
generic error handler was set. Many downstream test suites rely on this
behavior.
2023-12-25 23:38:40 +01:00
Nick Wellnhofer
c1bddd4c26 parser: Mark 'length' member of xmlParserInput as unused 2023-12-25 23:38:40 +01:00
Nick Wellnhofer
955c177f69 parser: Stop using 'directory' struct member
This was only used as a pointless fallback for URI resolution.
2023-12-25 23:38:40 +01:00
Nick Wellnhofer
60841beba6 parser: Make XML_IO_NETWORK_ATTEMPT behave as before
Always reported to generic error, not to parser context for backward
compatibility. Several downstream test suites rely on this behavior.
2023-12-25 23:38:40 +01:00
Nick Wellnhofer
a26934105e io: Move some code from xmlIO.c to parserInternals.c
Move everything related to parser contexts to parserInternals.c.
2023-12-25 23:38:40 +01:00
Nick Wellnhofer
8ab1b122c4 Fix filename and URI handling
Many strings are passed to the library that could be either URIs or
filesystem paths. We now assume that strings are a URI if they contain
the substring "://". This means that they have a scheme and an
authority. Otherwise, URI resolution wouldn't make much sense.

Fix xmlBuildURI to work with filesystem paths. If the base URI doesn't
contain "://" it is treated as filename. The resolved URI is unescaped,
appended and the result is normalized. Rewrite xmlNormalizePath to
handle Windows quirks.

All special handling for Windows paths is removed in xmlCanonicPath.
If the path looks like an URI, only escape characters allowed in Legacy
Extended IRIs.

Make xmlPathToURI only call xmlCanonicPath. Theh additional round-trip
through URI parser and serializer seems useless.

Add a helper function xmlConvertUriToPath in xmlIO.c which checks for
file URIs and unescapes them.

Always process strings with xmlCanonicPath in xmlLoadExternalEntity.
This should be harmless now.

Should help with #334, #387, #611.
2023-12-25 23:38:40 +01:00
Nick Wellnhofer
28913232f6 uri: Clean up special parsing modes
Add function to handle unreserved check. Give flags meaningful names.
Add support to allow ucschars from Legacy Extended IRIs.
2023-12-25 23:38:40 +01:00
Nick Wellnhofer
6e3a2ac660 xinclude: Rework xml:base fixup
The xml:base fixup was broken in more complex cases.

Also avoid parsing and building the included URI multiple times.
2023-12-25 23:38:40 +01:00
Nick Wellnhofer
35a4bc50d0 xinclude: Report to xmlGenericError 2023-12-25 23:38:40 +01:00
Nick Wellnhofer
e8de3401b3 parser: Also set document properties when push parsing
Add new function xmlFinishDocument which invokes the endDocument SAX
handler and sets the document's properties.
2023-12-25 23:38:40 +01:00
Nick Wellnhofer
c73de050f5 include: Move non-generated parts from xmlversion.h.in
xmlexports.h originally only included symbol visibility macros but it's
a good place for other macros as well.
2023-12-25 23:38:40 +01:00
Nick Wellnhofer
a18d94168b Update NEWS 2023-12-24 22:11:49 +01:00
Nick Wellnhofer
229e5ff7f9 io: Remove support for HTTP POST
This feature is unlikely to be used these days.
2023-12-24 22:11:49 +01:00
Nick Wellnhofer
9c2c87b55d dict: Move local RNG state to global state
Don't use TLS variables directly.
2023-12-24 16:24:34 +01:00
Nick Wellnhofer
2e9e758d1e dict: Get random seed from system PRNG 2023-12-24 16:24:34 +01:00
Nick Wellnhofer
c49572e57d malloc-fail: Fix erroneous report in xmlStringGetNodeList
The parser can produce invalid attribute content in recovery mode.
Unless this is fixed, xmlStringGetNodeList should ignore such errors
silently.
2023-12-23 15:10:15 +01:00
Nick Wellnhofer
c8f1f4a280 doc: Improve documentation of error handlers 2023-12-21 17:36:17 +01:00
Nick Wellnhofer
882b3a8075 runtest: Fix return code in rngTest 2023-12-21 15:34:24 +01:00
Nick Wellnhofer
f0df3e6d00 tests: Try to fix RelaxNG test cases
These were added recently in ea695ac0 and 8074b881 but were a total mess
of symbolic links and apparently mixed up files.

Symbolic links don't work on Windows.

Try to salvage one of the tests.
2023-12-21 15:02:24 +01:00
Nick Wellnhofer
8cd563174a html: Don't close fd in htmlCtxtReadFd
Long-standing bug. The XML fix from 2003 was never ported to the HTML
parser. htmlReadFd was fixed with fe6890e2.
2023-12-21 15:02:24 +01:00
Nick Wellnhofer
0a658c0f0a io: Don't use "-" to read from stdin
To implement this feature on such a low level is a disaster waiting to
happen. Remove these checks from the IO code and move them to xmllint.

Note that the serialization API will still treat "-" as stdout.
2023-12-21 15:02:24 +01:00
Nick Wellnhofer
c9a46a91fe io: Rework initialization 2023-12-21 15:02:24 +01:00
Nick Wellnhofer
b75fc1ab33 io: Rearrange code 2023-12-21 15:02:24 +01:00
Nick Wellnhofer
130436917c parser: Rename xmlErrParser to xmlCtxtErr 2023-12-21 15:02:24 +01:00
Nick Wellnhofer
8d0aaf4b95 parser: Remove xmlErrEncoding
Use xmlFatalErr or xmlCtxtErrIO.
2023-12-21 15:02:24 +01:00
Nick Wellnhofer
9fbe46ba17 io: Consolidate error messages 2023-12-21 15:02:24 +01:00
Nick Wellnhofer
23345a1cb1 io: Report IO errors through xmlCtxtErrIO
This is also a new public API function to be used in external entity
loaders.
2023-12-21 15:02:24 +01:00
Nick Wellnhofer
e62b0dbde5 xzlib: Fix harmless unsigned integer overflow 2023-12-21 15:02:24 +01:00
Nick Wellnhofer
1ef3566362 io: Always use unbuffered input
Before, we often used unbuffered input via the lzma or gzip handlers,
more or less inadvertently.

Change the default file handlers from buffered (stdc FILE) to unbuffered
(POSIX fds).
2023-12-21 15:02:24 +01:00
Nick Wellnhofer
7e14c05df2 io: Fix detection of compressed streams
Make sure that we don't try to open uncompressed streams with a
compression handler in copying mode.
2023-12-21 15:02:24 +01:00
Nick Wellnhofer
7e511f35f1 io: Pass error codes from xmlFileOpenReal to xmlNewInputFromFile
This allows to report the reason why opening a file failed to the parser
context and improve error messages. Now we can also remove the stat call
before opening a file.
2023-12-21 15:02:24 +01:00
Nick Wellnhofer
b2dbcc432b io: Rework default callbacks
Register a dummy callback struct for default callbacks. Handle them in a
separate function which will later allow to return meaningful error
codes.
2023-12-21 15:02:24 +01:00
Nick Wellnhofer
531d06add6 error: Stop printing some errors by default
Unfortunately, it's long-standing behavior for libxml2 to print all
reported errors to stderr by default. This default behavior is now
partially disabled. If no error handler is set, only parser and
validation errors are passed to a generic error handler or printed to
stderr. Other errors are still available via xmlGetLastError and can be
captured with a structured error handler.
2023-12-21 15:02:24 +01:00
Nick Wellnhofer
0c7a364f57 error: Remove xmlSimpleError 2023-12-21 15:02:24 +01:00
Nick Wellnhofer
f9f5c2d889 xmllint: Don't use xmlGenericError 2023-12-21 15:02:24 +01:00
Nick Wellnhofer
e9c01c30a3 runtest: Test with per-context error handlers
Only set the global error handler where needed.

Don't use xmlGenericError.
2023-12-21 15:02:24 +01:00
Nick Wellnhofer
05d9bacd05 regexp: Improve error handling
Handle malloc failure from xmlRaiseError.

Use xmlRaiseMemoryError.

Remove argument from memory error handler.

Remove TODO macro.
2023-12-21 15:02:24 +01:00
Nick Wellnhofer
ecb4c9fb28 misc: Improve error handling
Remove calls to generic error handler or use stderr for

- legacy deprecation warnings
- nanohttp, nanoftp in standalone mode
- memory debug messages

Use xmlRaiseMemoryError.

Remove TODO macro.

Don't raise errors in xmlmodule.c.
2023-12-21 15:02:24 +01:00
Nick Wellnhofer
bc1e030664 save: Improve error handling
Handle malloc failrue from xmlRaiseError.

Use xmlRaiseMemoryError.

Stop using xmlGenericError.

Remove argument from memory error handler.

Remove TODO macro.
2023-12-21 15:02:24 +01:00
Nick Wellnhofer
664db89e0e schematron: Improve error handling
Implement xmlSchematronVErr.

Handle malloc failure from xmlRaiseError.

Stop using xmlGenericError.

Remove argument from memory error handler.

Use xmlRaiseMemoryError.

Remove TODO macro.
2023-12-21 15:02:24 +01:00
Nick Wellnhofer
83c6aeef49 relaxng: Improve error handling
Pass RelaxNG structured error handler to XML parser.

Handle malloc failure from xmlRaiseError.

Remove argument from memory error handler.

Use xmlRaiseMemoryError.

Don't use xmlGenericError.

Remove TODO macro.
2023-12-21 15:01:42 +01:00