HTMLparser.c


Log

Author Commit Date CI Message
Nick Wellnhofer 6b50d8c8 2025-06-08T13:05:22 html: Add missing call to grow parser in htmlParseComment Otherwise, long chains of short comments could exhaust the input buffer when pull parsing.
Nick Wellnhofer 70335c41 2025-06-06T03:29:57 html: Don't stop on unsupported encoding Continue to parse unlike in the XML case.
Nick Wellnhofer 416da89d 2025-06-04T20:49:16 html: Make htmlCtxtReset call xmlCtxtReset The two implementations shouldn't diverge.
Nick Wellnhofer c6206c93 2025-06-05T21:06:11 html: Ignore ASCII-incompatible encoding in meta tag After successfully parsing an ASCII-encoded meta tag, switching to an encoding that isn't ASCII-compatible cannot work.
Nick Wellnhofer 6a6a46f0 2025-05-28T16:02:41 doc: Fix autolink errors Fix links, remove links to internal functions.
Nick Wellnhofer 7bd8d1d9 2025-05-28T15:53:38 doc: Prefix autolinks with '#' Use `#func` instead of `func()` to ignore parameters and make all autolinks work.
Nick Wellnhofer c5b45fbc 2025-05-16T16:54:09 doc: Misc fixes
Nick Wellnhofer 6f4b4527 2025-05-15T23:43:32 parser: Stop using ctxt->linenumbers I think this was used to avoid setting the `line` member before it was added (20+ years ago).
Nick Wellnhofer 258d8706 2025-05-15T17:49:49 codegen: Consolidate tools for code generation Move tools, source files and output tables into codegen directory. Rename some files. Adjust tools to match modified files. Remove generation date and source files from output. Distribute all tools and sources.
Nick Wellnhofer adfbeb7e 2025-05-14T04:58:21 doc: Stop using *Ptr typedefs in documentation
Nick Wellnhofer a40f36e7 2025-05-14T04:04:28 include: Stop using *Ptr typedefs in public headers
Nick Wellnhofer 2d83a84c 2025-05-14T00:29:19 doc: Misc improvements
Nick Wellnhofer f0983199 2025-05-12T13:00:20 html: Map some encodings according to HTML5 Windows-1252 is a superset of ISO-8859-1 and should be used instead. Same for ASCII. Also map UCS-2 and UTF-16 to UTF-16LE.
Nick Wellnhofer 05b8fe0a 2025-04-12T23:10:40 html: Don't escape RAWTEXT and PLAINTEXT Align with HTML5.
Nick Wellnhofer 809ded58 2025-04-12T22:50:56 html: Add more empty elements Add empty HTML5 elements <bgsound>, <keygen>, <source>, <track> and <wbr>. Make <embed> an empty element.
Nick Wellnhofer c7c49643 2025-05-09T15:26:15 html: Move DTD creation to endDocument SAX callback
Nick Wellnhofer 46f05ea4 2025-05-09T00:21:47 html: Rework meta charset handling Don't use encoding from meta tags when serializing. Only use the value in `doc->encoding`, matching the XML serializer. This is the actual encoding used when parsing. Stop modifying the input document by setting meta tags before serializing. Meta tags are now injected during serialization. Add full support for <meta charset=""> which is also used when adding meta tags. Align with HTML5 and implement the "algorithm for extracting a character encoding from a meta element". Only modify the encoding substring in Content-Type meta tags. Only switch encoding once when parsing. Fix htmlSaveFileFormat with a NULL encoding not to declare a misleading UTF-8 charset. Fixes #909.
Nick Wellnhofer f3a080bc 2025-05-07T14:32:42 html: Ignore U+0000 in body text Align with HTML5. Fixes #908.
Nick Wellnhofer 9bbffec5 2025-05-06T17:42:46 doc: Move brief to top, params to bottom of doc comments
Nick Wellnhofer b7274fb0 2025-05-03T16:34:02 doc: Misc fixes to HTML parser docs
Nick Wellnhofer 4a010875 2025-05-03T15:38:15 doc: Move parser option docs to enum
Nick Wellnhofer cb1635a6 2025-05-02T19:05:25 doc: Use @since command
Nick Wellnhofer e78e05c9 2025-05-02T17:32:51 doc: Fix autolinks to functions Unfortunately, autolinks in .c files aren't converted by Doxygen for some reason.
Nick Wellnhofer f7c41287 2025-05-02T15:57:17 doc: Remove more comment block headers
Nick Wellnhofer e525564f 2025-05-01T19:20:06 doc: Remove empty lines at start of block These lines were left over after automatic conversion.
Nick Wellnhofer e549622b 2025-04-28T15:11:24 doc: Convert documentation to Doxygen Automated conversion based on a few regexes.
Nick Wellnhofer 69879da8 2025-04-28T14:04:30 doc: Remove email addresses from documentation Also remove authorship information from generated files, hash.c and globals.c which were rewritten.
Nick Wellnhofer 61890e39 2025-04-27T21:50:15 doc: Prepare for conversion to Doxygen Fix many params in internal functions (not really necessary but Doxygen warns about that in XML mode). Fix formatting in a few corner cases that automatic conversion can't handle. Rearrange some DOC_DISABLE blocks.
Nick Wellnhofer 4ba1f923 2025-04-18T17:28:24 html: Avoid HTML_PARSE_HTML5 clashing with XML_PARSE_NOENT There are several users that pass invalid XML parser options to the HTML parser. Choose a value that is less likely to clash.
Nick Wellnhofer b8018afa 2025-04-09T23:30:47 html: Fix documentation of parser options
Nick Wellnhofer 2ecc08f6 2025-04-09T21:11:47 html: Deprecate more functions
Nick Wellnhofer 69b83bb6 2025-03-10T02:18:51 encoding: Detect truncated multi-byte sequences with ICU Unlike iconv or the internal converters, ICU consumes truncated multi- byte sequences at the end of an input buffer. We currently check for a non-empty raw input buffer to detect truncated sequences, so this fails with ICU. It might be possible to inspect the pivot buffer pointers, but it seems cleaner to implement a `flush` flag for some encoding and I/O functions. After flushing, we can check for U_TRUNCATED_CHAR_FOUND with ICU, or detect remaining input with other converters. Also fix detection of truncated sequences for HTML, XML content and DTDs with iconv.
Nick Wellnhofer 8873a498 2025-03-09T16:21:13 html: Fix areBlanks check Short-lived regression from 71122421.
Nick Wellnhofer 5f0b1378 2025-03-08T22:07:15 parser: Add more parser context accessors Fixes #763.
Nick Wellnhofer 5237d90f 2025-03-07T21:15:20 html: Process data before switching encoding This reduces the amount of data to convert and avoids issues with EOF detection. Also reset EOF flag after switching encoding as a precaution.
Nick Wellnhofer 0b27097a 2025-03-04T12:55:25 encoding: Rename unprefixed public functions
Nick Wellnhofer 5ed4eafd 2025-02-22T14:51:39 html: Don't invoke SAX callbacks if parser was stopped
Nick Wellnhofer 63dfcca6 2024-12-16T01:34:29 fuzz: Reduce initial array size
Nick Wellnhofer b8234e8c 2025-02-19T12:53:32 html: Fix check for partial named character references Digits are allowed after the first character.
Nick Wellnhofer 7a61c32b 2025-02-13T23:09:28 html: Use enum instead of magic values for insertion modes
Nick Wellnhofer 8cf6129b 2025-02-13T18:20:46 html: Stop implying <p> start tags Only <html>, <head> or <body> should be implied. Opening extra <p> tags has always been a libxml2 quirk.
Nick Wellnhofer 71122421 2025-02-13T14:04:10 html: Make implied <p> tags more deterministic libxml2's HTML parser adds <p> start tags in some situations. This behavior, which doesn't follow any standard, was added in 2000, see here: http://veillard.com/XML/messages/0655.html Text nodes that only contain whitespace don't imply a <p> tag, but the whitespace check cannot work reliably if we're parsing partial text data which can happen with both pull and push parser. The logic in `areBlanks` is hard to follow. The checks involving `CUR` depend on the position of the input pointer and seem dubious. It's also possible that the behavior changed inadvertently with a later commit. As a result, it's hard to come up with good test cases. We now process leading whitespace before creating implied tags. This is more in line with HTML5 and should avoid at least some issues with partial text data. For example, parsing the string "<head> x" used to result in: <html> <head></head> <body><p> x</p></body> </html> And now results in: <html> <head> </head> <body><p>x</p></body> </html> Except for the implied <p> tag, this matches HTML5.
Nick Wellnhofer 8d7e38d5 2025-02-01T22:41:53 fuzz: Ignore encodings when fuzzing on Apple Not long ago, Apple decided to replace GNU libiconv with a patched up version of FreeBSD's iconv implementation in their operating systems. Unfortunately, the quality of both the original implementation as well as Apple's patches is so abysmal that you routinely find issues when fuzzing your own code.
Nick Wellnhofer 68be036f 2025-02-01T22:09:18 fuzz: Disable HTML encoding detection for now This doesn't work with the push parser.
Nick Wellnhofer c13fcc19 2025-02-01T19:36:06 html: Chunk text data in push parser Follow the logic of the XML parser and chunk large text nodes.
Nick Wellnhofer 08028572 2025-02-01T18:21:47 html: Make data parsing modes work with push parser This can't be solved with a simple scan for a terminator. Instead, we make htmlParseCharData handle incomplete data if the "partial" flag is set.
Nick Wellnhofer 4be1e8be 2025-02-01T15:00:26 html: Simplify htmlParseTryOrFinish a little
Nick Wellnhofer 12732592 2025-02-01T00:36:12 html: Remove unused epilog state
Nick Wellnhofer 70bf754e 2025-02-01T00:17:01 html: Fix pull-parsing of incomplete end tags Handle this HTML5 quirk in htmlParseEndTag.
Nick Wellnhofer 4a776c78 2025-01-31T23:57:44 html: Use htmlParseElementInternal in push parser
Nick Wellnhofer ba153737 2025-01-31T22:51:59 html: Fix corner case when push-parsing HTML5 comments
Nick Wellnhofer e48fb5e4 2025-01-31T22:08:13 html: Handle incomplete UTF-8 when push-parsing For now, incomplete UTF-8 is always an error in push mode. Eventually, we could pass chunked data to the character handler when push-parsing. Then we'd have to handle incomplete sequences.
Nick Wellnhofer 6bb2ea8e 2025-02-01T14:58:06 html: Adjust xmlDetectEncoding for HTML Don't check for UTF-32 or EBCDIC. We now perform BOM sniffing and the first step of the HTML5 prescan algorithm (detect UTF-16 XML declarations). The rest of the algorithm still has to be implemented.
Nick Wellnhofer 227d8f73 2025-01-31T21:05:22 html: Support encoding auto-detection in push parser Align with pull parser.
Nick Wellnhofer 641fb1ac 2025-01-31T20:41:28 html: Fix state update in push parser
Nick Wellnhofer a86a8ae9 2025-01-31T20:09:54 html: Fix push-parsing of empty documents Also simplify end-of-document handling in push parser. Align with pull parser.
Nick Wellnhofer ca819160 2025-01-03T20:50:08 include: Use intptr_t to cast between pointers and ints
Nick Wellnhofer 53c131f6 2024-12-26T20:29:58 doc: Make apibuild.py work again
Nick Wellnhofer 0447275e 2024-12-15T21:17:07 html: Check reallocations for overflow
Nick Wellnhofer 6548ba11 2024-12-13T16:37:40 parser: Fix argument checks in xmlCtxtParse* - Raise invalid argument error. - Free input stream if ctxt is NULL.
Nick Wellnhofer 497081ba 2024-11-17T20:25:07 parser: Remove remaining calls to xml{Push|Pop}Input
Nick Wellnhofer 0f4f8900 2024-11-17T20:13:14 parser: Rename inputPush to xmlCtxtPushInput
Nick Wellnhofer 225ed707 2024-09-26T22:38:24 html: Accelerate htmlParseCharData
Nick Wellnhofer 20799979 2024-09-26T17:09:40 html: Handle numeric character references directly
Nick Wellnhofer 0bc4608c 2024-09-15T20:28:49 html: Use hash table to check for duplicate attributes
Nick Wellnhofer 24a6149f 2024-09-15T19:18:40 html: Make sure that character data mode is reset
Nick Wellnhofer c32397d5 2024-09-12T22:39:05 html: Improve character class macros
Nick Wellnhofer e8406554 2024-09-12T15:21:03 html: Rewrite parsing of most data
Nick Wellnhofer f77ec16d 2024-09-12T01:45:34 html: Optimize htmlParseCharData
Nick Wellnhofer 440bd64c 2024-09-12T04:01:38 html: Optimize htmlParseHTMLName
Nick Wellnhofer 6040785a 2024-09-12T23:12:01 html: Deprecate AutoClose API
Nick Wellnhofer 188cad68 2024-09-12T02:51:20 html: Remove obsolete content model
Nick Wellnhofer 0144f662 2024-09-12T02:30:10 html: Remove obsolete code
Nick Wellnhofer 575be6c1 2024-09-12T01:40:07 html: Fix line numbers with CRs
Nick Wellnhofer be874d78 2024-09-11T19:47:07 html: Ignore unexpected DOCTYPE declarations
Nick Wellnhofer 462bf0b7 2024-09-11T19:06:06 html: Rework options Introduce htmlCtxtSetOptions, see similar changes made to XML parser. Add HTML_PARSE_HUGE alias. Support HTML_PARSE_BIG_LINES.
Nick Wellnhofer 42c3823d 2024-09-11T19:05:09 html: Update comment
Nick Wellnhofer 9f04cce6 2024-09-11T17:43:07 html: Remove unused or useless return codes htmlParseStartTag should always succeed (except for malloc failures).
Nick Wellnhofer e179f3ec 2024-09-11T17:29:59 html: Stop reporting syntax errors It doesn't make much sense to keep the old syntax error handling which doesn't conform to HTML5. Handling HTML5 parser errors is rather involved and not essential for parsers.
Nick Wellnhofer 27752f75 2024-09-11T15:06:55 html: Fix EOF handling in start tags
Nick Wellnhofer b19d3539 2024-09-11T15:03:49 html: Fix EOF handling in comments
Nick Wellnhofer 17e56ac5 2024-09-11T14:24:58 html: Fix parsing of end tags
Nick Wellnhofer 24a09033 2024-09-09T02:53:14 html: Fix bogus end tags
Nick Wellnhofer bca64854 2024-09-09T02:30:18 html: Allow U+000C FORM FEED as whitespace
Nick Wellnhofer 6edf1a64 2024-09-09T02:09:20 html: Fix DOCTYPE parsing
Nick Wellnhofer 9678163f 2024-09-09T02:01:19 html: Don't check for valid XML characters
Nick Wellnhofer a6955c13 2024-09-08T23:19:49 html: Parse numeric character references according to HTML5
Nick Wellnhofer 4eeac309 2024-09-08T22:20:20 html: Start to fix EOF and U+0000 handling
Nick Wellnhofer e062a4a9 2024-09-08T20:40:36 html: Add HTML5 parser option This option passes tokenizer output directly to the SAX callbacks, making it possible to test the tokenizer against the html5lib test suite. This will produce unbalanced calls to the startElement and endElement callbacks, but it's the only way to support a SAX like interface for HTML5. It can be used for filtering or rewriting HTML5, for example. A HTML5 tree builder could then be implemented on top of the SAX callbacks.
Nick Wellnhofer 17da54c5 2024-09-08T19:16:12 html: Normalize newlines
Nick Wellnhofer 341dc78f 2024-09-08T19:11:14 html: Deduplicate code in htmlCurrentChar
Nick Wellnhofer 3adb396d 2024-09-07T15:18:13 html: Parse bogus comments instead of ignoring them Also treat XML processing instructions as bogus comments.
Nick Wellnhofer 84440175 2024-09-07T14:21:12 html: Add missing calls to htmlCheckParagraph()
Nick Wellnhofer 86d6b9b0 2024-09-07T04:18:06 html: Deduplicate some code
Nick Wellnhofer 0d324bde 2024-09-07T03:45:09 html: Simplify node info accounting
Nick Wellnhofer ccb61f59 2024-09-07T03:15:50 html: Remove duplicate calls to htmlAutoClose
Nick Wellnhofer f9ed30e9 2024-09-06T17:49:04 html: HTML5 character data states
Nick Wellnhofer 59511792 2024-09-03T15:52:44 html: Parse named character references according to HTML5
Nick Wellnhofer d5cd0f07 2022-07-15T17:00:36 html: Prefer SKIP(1) over NEXT in HTML parser Use SKIP(1) where it's safe to avoid a function call.
Nick Wellnhofer dc2d4983 2023-05-04T17:47:38 html: Rework htmlLookupSequence Rename to htmlLookupString and use strstr for increased performance.