parserInternals.c


Log

Author Commit Date CI Message
Nick Wellnhofer bd9eed46 2024-09-02T18:37:41 parser: Make unsupported encodings an error in declarations This was changed in 45157261, but in encoding declarations, unsupported encodings should raise a fatal error. Fixes #794.
Nick Wellnhofer 1d009fe3 2024-08-05T15:14:21 parser: Report at least one fatal error
Nick Wellnhofer bfed6e6a 2024-08-05T14:58:37 parser: Fix error handling after reaching limit Mark document as non-wellformed and stop parser even if error limit was reached. Regressed in abd74186.
Nick Wellnhofer 6a3c0b0d 2024-07-22T12:53:00 parser: Increase XML_MAX_DICTIONARY_LIMIT This limit is somewhat arbitrary and can be reached when fuzzing documents up to 1 MB. Increase limit to 100 MB and disable limit if XML_PARSE_HUGE is set.
Nick Wellnhofer a6f54f05 2024-07-07T18:52:17 io: Fine-tune initial IO buffer size
Nick Wellnhofer 34c9108f 2024-07-07T18:38:31 encoding: Add sizeOut argument to xmlCharEncInput When push parsing, we want to convert as much of the input as possible. When pull parsing memory buffers, we want to convert data chunk by chunk to save memory.
Nick Wellnhofer 92f30711 2024-07-07T03:02:11 parser: Optimize buffer shrinking Remove checks now that we can shrink memory buffers efficiently. Shrink more aggressively.
Nick Wellnhofer a221cd78 2024-07-07T03:01:51 buf: Rework xmlBuf code Always use what the old implementation called the "IO" allocation scheme, allowing to move the content pointer past the initial allocation. This is inexpensive and allows efficient shrinking. Optimize xmlBufGrow, reusing shrunken memory as much as possible. Simplify xmlBufAdd. Make xmlBufBackToBuffer return an error on overflow. Make "size" exclude the terminating NULL byte. Always provide an initial size. Reintroduce static buffers. Remove xmlBufResize and several other functions.
Nick Wellnhofer 72886980 2024-07-15T14:35:47 error: Add helper functions to print errors and abort
Nick Wellnhofer aa6aec19 2024-07-11T12:37:25 parser: Fix xmlInputSetEncodingHandler again Short-lived regression.
Nick Wellnhofer 8af55c8d 2024-07-06T22:14:21 parser: Rename new input API functions These weren't made public yet.
Nick Wellnhofer d74ca594 2024-07-06T22:04:06 parser: Rename internal xmlNewInput functions
Nick Wellnhofer 4f329dc5 2024-07-10T03:27:47 parser: Implement xmlCtxtParseContent This implements xmlCtxtParseContent, a better alternative to xmlParseInNodeContext or xmlParseBalancedChunkMemory. It accepts a parser context and a parser input, making it a lot more versatile. xmlParseInNodeContext is now implemented in terms of xmlCtxtParseContent. This makes sure that xmlParseInNodeContext never modifies the target document, improving thread safety. xmlParseInNodeContext is also more lenient now with regard to undeclared entities. Fixes #727.
Nick Wellnhofer 4fec0889 2024-07-10T22:31:15 parser: Fix memory leak in xmlInputSetEncodingHandler Short-lived regression.
Nick Wellnhofer 59354717 2024-07-09T13:54:07 parser: Fix malloc failure handling in xmlInputSetEncodingHandler Don't set encoder if allocating buffer failed. This could lead to xmlByteConsumed processing invalid UTF-8.
Nick Wellnhofer ea31ac5b 2024-07-07T01:02:11 fuzz: Fix spaceMax
Nick Wellnhofer 29e3ab92 2024-07-06T15:48:43 fuzz: Make reallocs more likely
Nick Wellnhofer 38195cf5 2024-07-06T14:58:16 parser: Don't produce names with invalid UTF-8 in recovery mode
Nick Wellnhofer ec088109 2024-07-04T15:15:17 parser: Upgrade XML_IO_NETWORK_ATTEMPT to error Fixes XML::LibXML test suite.
Nick Wellnhofer fdfeecfe 2024-07-02T21:54:26 parser: Reenable ctxt->directory Unused internally, but used in downstream code. Should fix #753.
Nick Wellnhofer 606f4108 2024-07-02T20:57:15 parser: Allow to disable catalogs with parser options Implement XML_PARSE_NO_SYS_CATALOG and XML_PARSE_NO_CATALOG_PI. Fixes #735.
Nick Wellnhofer 197e09d5 2024-07-02T19:46:51 parser: Fix xmlLoadResource Short-lived regression.
Nick Wellnhofer ede5d99a 2024-07-02T01:42:33 parser: Fix typo
Nick Wellnhofer 30ef7755 2024-07-02T04:02:16 parser: Don't use deprecated xmlCopyChar
Nick Wellnhofer 751ba00e 2024-07-02T03:41:05 parser: Don't use deprecated xmlSwitchInputEncoding
Nick Wellnhofer 9a4770ef 2024-07-02T02:18:03 doc: Improve documentation
Nick Wellnhofer 0b0dd989 2024-06-28T23:13:38 parser: Fix EBCDIC detection
Nick Wellnhofer 221df375 2024-06-28T00:34:52 parser: Support custom charset conversion implementations Implement xmlCtxtSetCharEncConvImpl. I agree that the name is terrible.
Nick Wellnhofer e72eda10 2024-06-28T01:41:36 parser: Add NULL check in xmlNewIOInputStream
Nick Wellnhofer bc793390 2024-06-27T16:23:14 parser: Update documentation
Nick Wellnhofer 193f4653 2024-06-26T19:28:28 parser: Implement xmlCtxtGetStatus This allows access to ctxt->wellFormed, ctxt->nsWellFormed and ctxt->valid. It also detects several fatal non-parser errors which really should be another error level.
Nick Wellnhofer cc0cc2d3 2024-06-26T04:32:49 parser: Add more parser context accessors
Nick Wellnhofer eca972e6 2024-06-26T02:22:04 parser: Add getters for XML declaration to parser context Access to struct members will be deprecated.
Nick Wellnhofer 3ff8a2c4 2024-06-26T01:08:48 parser: Deprecate xmlIsLetter
Nick Wellnhofer fa50be92 2024-06-25T23:19:56 parser: Move implementation of xmlCtxtGetLastError
Rosen Penev 217e9b7a 2024-06-08T12:27:45 clang-tidy: don't return in void functions Found with readability-redundant-control-flow Signed-off-by: Rosen Penev <rosenp@gmail.com>
Nick Wellnhofer c5e9a5b2 2024-06-17T15:29:56 parser: Use catalogs with resource loader
Nick Wellnhofer 6deebe03 2024-06-17T13:09:37 parser: Make xmlInputCreateUrl handle HTTP input
Nick Wellnhofer d2fd9d37 2024-06-17T12:55:44 parser: Fix swapped arguments
Nick Wellnhofer 2608baaf 2024-06-14T19:42:40 parser: Make failure to load main document a warning Revert the change that made failures to load the main document an error. This fixes the --path option of xmllint and xsltproc. Should fix #733.
Nick Wellnhofer dba1ed85 2024-06-12T18:19:55 ftp: Remove FTP support Remove the built-in FTP client. If you configure --with-legacy, old symbols are retained for ABI compatibility.
Nick Wellnhofer 52384043 2024-06-11T19:10:41 parser: Pass resource type to resource loader
Nick Wellnhofer ab5e6deb 2024-06-11T18:11:51 parser: Introduce XML_INPUT_NETWORK input flag This allows to disable network access when creating parser inputs with xmlInputCreateUrl.
Nick Wellnhofer 89fcae4d 2024-06-11T16:19:58 parser: Don't report malloc failures when creating context We don't want messages to stderr before an error handler could be set on a parser context.
Nick Wellnhofer 64ad2725 2024-06-11T03:51:43 parser: Introduce per-context resource loader
Nick Wellnhofer b9d2f3c9 2024-06-11T02:15:18 parser: Introduce new input API - xmlInputCreateUrl - xmlInputCreateMemory - xmlInputCreateString - xmlInputCreateFd - xmlInputCreateIO - xmlInputSetEncoding These functions don't take a parser context and work on xmlParserInputs, replacing functions working on xmlParserInputBuffers. xmlInputCreateUrl and xmlInputSetEncoding offer fine-grained error handling. Several XML_INPUT_* flags offer additional control.
Nick Wellnhofer 410931e3 2024-06-11T00:55:38 parser: Only set input ID for PE refs Other input streams don't require IDs.
Nick Wellnhofer a3b2baeb 2024-06-11T00:52:04 parser: Simplify xmlNewInputFromFile
Nick Wellnhofer 0b588387 2024-06-11T00:37:11 parser: Rework XML_PARSE_NONET handling
Nick Wellnhofer ff3b0919 2024-06-11T00:00:32 parser: Implement XML_PARSE_NO_UNZIP option
Nick Wellnhofer 1432949d 2024-06-10T23:57:52 io: Pass input flags to xmlParserInputBufferCreateUrl
Nick Wellnhofer b5890cb4 2024-06-10T18:51:56 io: Remove xmlParserInputBufferCreateFilenameSafe
Nick Wellnhofer 1b1e8b3c 2024-06-10T16:39:57 io: Stop invoking generic error handler for IO errors
Nick Wellnhofer 47cbb6bb 2024-06-10T14:04:00 doc: Don't mention xmlNewInputURL
Nick Wellnhofer 4467b891 2024-06-12T13:32:32 Add missing argument checks for new API functions
Nick Wellnhofer e75e878e 2024-05-20T13:58:22 doc: Update and fix documentation
Nick Wellnhofer ec2f68f1 2024-05-14T15:58:44 parser: Report malloc failure in xmlNewInputFromFile
Nick Wellnhofer 4ff2dccf 2024-05-10T02:04:52 SAX2: Warn if URI resolution failed
Nick Wellnhofer 84a71860 2024-02-26T15:14:28 xmlreader: Fix xmlTextReaderConstEncoding Regression from commit f1c1f5c6. Fixes #697.
Nick Wellnhofer c444c96e 2024-02-13T12:22:28 parser: Report OOM errors even after parser was stopped
Nick Wellnhofer 63986c45 2024-01-22T21:02:16 parser: Report fatal error if document entity couldn't be loaded Only lower error level when loading entities. Fixes #667.
Nick Wellnhofer 12f0bb94 2024-01-05T01:14:28 parser: Synchronize more options
Nick Wellnhofer 3efbe916 2024-01-05T00:11:29 parser: Mark 'token' member as unused in xmlParserCtxt
Nick Wellnhofer b82fd81d 2024-01-04T23:25:06 parser: Rework xmlCtxtParseDocument Make xmlCtxtParseDocument take a parser input which can be popped after parsing.
Nick Wellnhofer d0eb5a7e 2024-01-03T18:12:29 parser: Remove xmlErrEncodingInt Convert the last user to xmlFatalErr.
Nick Wellnhofer f30b9b23 2024-01-03T18:11:44 fuzz: Add assertion in xmlCopyCharMultibyte This is an internal function that should never receive out-of-range codepoints.
Nick Wellnhofer 0821efc8 2024-01-02T18:33:57 encoding: Check whether encoding handlers support input/output The "HTML" encoding handler doesn't support input which could lead to a wrong error report.
Nick Wellnhofer 85f99023 2024-01-02T17:52:43 parser: Fix buffer size checks Don't test size of remaining data. This causes false positives with memory buffers. Also impose XML_MAX_HUGE_LENGTH limit when parsing with XML_PARSE_HUGE.
Nick Wellnhofer 16b0dbc1 2023-12-29T18:47:30 parser: Fix XML_ERR_UNSUPPORTED_ENCODING errors Commit 45157261 added the check in the wrong place. Also allow unsupported encoding in xmlNewInputInternal. Fixes #654.
Nick Wellnhofer e45a4d71 2023-12-29T00:00:21 io: Always forward IO errors to global handler The HTTP module raises errors without context. This won't be fixed, so send them to the global error handler.
Nick Wellnhofer 7e0bbbc1 2023-12-27T18:33:30 parser: New input API Provide a new set of functions to create xmlParserInputs. These can be used for the document entity or from external entity loaders. - Don't require xmlParserInputBuffer. - All functions take a base URI. - All functions take an encoding as string. - xmlNewInputURL also takes a public ID. - xmlNewInputMemory takes a size_t. - Optimization hints for memory buffers. Improve documentation. Only call xmlInitParser before allocating a new parser context. Call xmlCtxtUseOptions as early as possible.
Nick Wellnhofer 45157261 2023-12-27T21:30:13 parser: Downgrade XML_ERR_UNSUPPORTED_ENCODING to warning If the actual encoding is UTF-8 or ASCII, we don't want to fail.
Nick Wellnhofer 24b7144f 2023-12-27T15:50:58 parser: More refactoring of entity parsing Remove xmlCreateEntityParserCtxtInternal. Rework xmlNewEntityInputStream.
Nick Wellnhofer 6a9a88a1 2023-12-26T03:13:05 parser: Move progressive flag into input struct
Nick Wellnhofer d944a415 2023-12-26T02:10:35 parser: Fix in-parameter-entity and in-external-dtd checks Use in ctxt->input->entity instead of ctxt->inputNr to determine whether we are inside a parameter entity. Stop using ctxt->external to check whether we're in an external DTD. This is signaled by ctxt->inSubset == 2.
Nick Wellnhofer c1bddd4c 2023-12-23T01:09:17 parser: Mark 'length' member of xmlParserInput as unused
Nick Wellnhofer 955c177f 2023-12-23T00:58:36 parser: Stop using 'directory' struct member This was only used as a pointless fallback for URI resolution.
Nick Wellnhofer 60841beb 2023-12-25T18:31:22 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.
Nick Wellnhofer a2693410 2023-12-23T00:35:30 io: Move some code from xmlIO.c to parserInternals.c Move everything related to parser contexts to parserInternals.c.
Nick Wellnhofer c8f1f4a2 2023-12-21T17:30:38 doc: Improve documentation of error handlers
Nick Wellnhofer 13043691 2023-12-20T00:33:34 parser: Rename xmlErrParser to xmlCtxtErr
Nick Wellnhofer 8d0aaf4b 2023-12-19T20:47:36 parser: Remove xmlErrEncoding Use xmlFatalErr or xmlCtxtErrIO.
Nick Wellnhofer 9fbe46ba 2023-12-19T20:10:10 io: Consolidate error messages
Nick Wellnhofer 23345a1c 2023-12-19T19:52:28 io: Report IO errors through xmlCtxtErrIO This is also a new public API function to be used in external entity loaders.
Nick Wellnhofer 7e511f35 2023-12-19T15:41:37 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.
Nick Wellnhofer 531d06ad 2023-12-18T22:48:24 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.
Nick Wellnhofer 54c70ed5 2023-12-18T19:31:29 parser: Improve error handling Introduce xmlCtxtSetErrorHandler allowing to set a structured error for a parser context. There already was the "serror" SAX handler but this always receives the parser context as argument. Start to use xmlRaiseMemoryError. Remove useless arguments from memory error functions. Rename xmlErrMemory to xmlCtxtErrMemory. Remove a few calls to xmlGenericError. Remove support for runtime entity debugging.
Nick Wellnhofer 69d88566 2023-12-15T14:46:35 malloc-fail: Fix OOM error handling in xmlSwitchInputEncoding Make sure that in->buffer won't be set to NULL if a memory allocation fails. Short-lived regression.
Nick Wellnhofer 79a9938d 2023-12-13T17:25:37 parser: Don't grow or shrink pull parser memory buffers Readd check for memory buffers without a read callback to avoid XML_MAX_LOOKUP_LIMIT errors if users provide a custom input buffer. Regressed with commit 834b8123 and later changes.
Nick Wellnhofer f19a9510 2023-12-10T17:50:22 parser: Report malloc failures Fix many places where malloc failures aren't reported. Make xmlErrMemory public. This is useful for custom external entity loaders. Introduce new API function xmlSwitchEncodingName. Change the way how we store whether the the parser is stopped. This used to be signaled by setting ctxt->instate to XML_PARSER_EOF which was misdesigned and error-prone. Set ctxt->disableSAX to 2 instead and introduce a macro PARSER_STOPPED. Also stop to remove parser inputs in xmlHaltParser. This allows to remove many checks of ctxt->instate. Introduce xmlErrParser to handle errors if a parser context is available.
Nick Wellnhofer bd5ad030 2023-12-10T14:56:21 encoding: Report malloc failures Introduce new API functions that return a separate error code if a memory allocation fails. - xmlOpenCharEncodingHandler - xmlLookupCharEncodingHandler Fix a few places where malloc failures weren't reported.
Nick Wellnhofer 43b511fa 2023-11-26T14:31:39 parser: Make CRLF increment line number Partial revert of cb927e85 fixing CRLFs not incrementing the line number. This requires to rework xmlParseQNameHashed. The original implementation prompted the change to xmlCurrentChar which really shouldn't modify the 'cur' pointer as side effect. But the NEXTL macro relies on this behavior. Ultimately, we should reintroduce the change to xmlCurrentChar and fix the NEXTL macro. This will lead to single CRs incrementing the line number as well which seems more consistent. Fixes #628.
Nick Wellnhofer ff6c3188 2023-11-23T15:22:59 include: Remove useless 'const' from function arguments
Nick Wellnhofer 02856674 2023-10-22T15:56:46 parser: Remove redundant IS_CHAR check in xmlCurrentChar
Nick Wellnhofer c082ef46 2023-08-09T16:59:36 parser: Stop switching to ISO-8859-1 on encoding errors Use U+FFFD Replacement Character if invalid UTF-8 is encountered in recovery mode. Also rewrite xmlNextChar and xmlCurrentChar. Fixes #598.
Nick Wellnhofer 572ecc17 2023-10-22T13:59:55 parser: Fix buffer shrinking when push parsing Short-lived regression from b76d81da.
Nick Wellnhofer b76d81da 2023-10-06T11:50:29 parser: Fix regression when push parsing parameter entities Short-lived regression from 834b8123. Also shrink parameter entity buffers when push parsing.
Nick Wellnhofer eb69c1d3 2023-10-02T12:16:05 parser: Fix initialization of namespace data Move initialization to xmlInitSAXParserCtxt. Also add missing XML_HIDDEN to xmlParserNsFree. Fixes #597.
Nick Wellnhofer e0dd330b 2023-09-29T00:18:44 parser: Use hash tables to avoid quadratic behavior Use a hash table to lookup namespaces by prefix. The hash table stores an index into the namespace table. Auxiliary data for namespaces is stored in a separate array along the main namespace table. Use a hash table to verify attribute uniqueness. The hash table stores an index into the attribute table. Reuse hash value from the dictionary to avoid computing them twice. See #346.
Nick Wellnhofer cb927e85 2023-09-25T14:35:43 parser: Don't skip CR in xmlCurrentChar Skip over carriage returns later in xmlNextChar.