Skip to content

fix!: report more non well-formed cases#519

Merged
karfau merged 15 commits into
masterfrom
fix/45
Jul 30, 2023
Merged

fix!: report more non well-formed cases#519
karfau merged 15 commits into
masterfrom
fix/45

Conversation

@karfau

@karfau karfau commented Jul 22, 2023

Copy link
Copy Markdown
Member

fatalError will throw a ParseError and stop processing the document:

  • consistently detect current tag name
  • report all possible cases of mismatching or unclosed tags in XML
    • case mismatches in HTML documents are not reported
  • report missing attribute value in XML
  • report unescaped < in AttrValue as fatalError (only in XML documents)
  • report occurrences of Unicode replacement character \ufffd

error doesn't stop processing unless onErrorStopParsing or a similar method is used:

  • report non white-space characters outside of elements (at the same level as the root element)

BREAKING-CHANGE: Reports more not well-formed documents as fatalError and drop broken support for optional and unclosed tags in HTML.

Closes #45
Closes #125
Closes #467

karfau added 2 commits July 22, 2023 21:18
- consistently detect current tagName
- report all possible cases as fatalError
- update tests for reported errors
- properly report missing attribute value (not in HTML)

BREAKING-CHANGE: Reports more not well-formed documents as fatalError.

Closes: #45
@karfau karfau linked an issue Jul 22, 2023 that may be closed by this pull request
@karfau karfau marked this pull request as draft July 23, 2023 00:05
BREAKING-CHANGE: Drops incomplete and broken support
for unclosed and optional end tags in HTML,
which was creating a similar looking but wrong DOM anyways,
if there was any content after the unclosed tag.

Closes #467
@karfau karfau marked this pull request as ready for review July 23, 2023 15:26
@karfau karfau changed the title fix!: report closing tag mismatches as fatalError fix!: report more non well-formed cases as fatalError Jul 23, 2023
@karfau karfau changed the title fix!: report more non well-formed cases as fatalError fix!: report more non well-formed cases Jul 25, 2023
@karfau karfau added this to the 0.9.0 milestone Jul 25, 2023
Comment thread test/html/__snapshots__/normalize.test.js.snap Outdated
karfau added 6 commits July 27, 2023 10:25
and make it harder to break/have false positives for the tests in the future
and report missing entries in REPORTED as `todo` tests,
which are treated like skip but counted separately.

Some can not easily be tested since there is no known test cases,
but the ones added in the current PR should now checked.
Comment thread test/error/reported.js
const data = JSON.stringify(LINE_TO_ERROR_INDEX, null, 2);
const currentData = fs.existsSync(REPORTED_JSON) ? fs.readFileSync(REPORTED_JSON, 'utf8') : '';
if (data !== currentData) {
fs.writeFileSync(REPORTED_JSON, data, 'utf8');

Check failure

Code scanning / CodeQL

Potential file system race condition

The file may have changed since it [was checked](1).

@karfau karfau Jul 29, 2023

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The additional check just avoids writing the file on every test run if the content doesn't change, which would trigger an endless loop when running the tests in watch mode. It's not relevant for the published code.

@karfau karfau added xml:not well-formed https://www.w3.org/TR/xml11/#dt-wellformed xml:well-formed https://www.w3.org/TR/xml11/#dt-wellformed spec:XML https://www.w3.org/TR/xml11/ testing labels Jul 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking change Some thing that requires a version bump due to breaking changes error handling spec:DOM-Parsing spec:HTML spec:XML https://www.w3.org/TR/xml11/ testing xml:not well-formed https://www.w3.org/TR/xml11/#dt-wellformed xml:well-formed https://www.w3.org/TR/xml11/#dt-wellformed

Projects

None yet

2 participants