Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Normalize white space characters and preserve references in attributes #291

Conversation

karfau
Copy link
Member

@karfau karfau commented Aug 21, 2021

BREAKING CHANGE: If you relied on the not spec compliant preservation of \t, \n or \r in attribute values. To preserve those you will have to create XML that instead contains the correct numerical (or hexadecimal) equivalent (	, 
, 
).

@karfau karfau marked this pull request as ready for review August 21, 2021 11:19
@karfau karfau added the breaking change Some thing that requires a version bump due to breaking changes label Aug 21, 2021
@brodycj
Copy link
Member

brodycj commented Aug 25, 2021

I don't see support or testing of the referenced "end-of-line handling". Should we add this or am I missing something here?

@karfau
Copy link
Member Author

karfau commented Aug 26, 2021

@brodybits yes, this is something that xmldom currently doesn't do and I consider this as a change outside of the scope of this fix.
But even though I mentioned it in the related issue, I'm also surprised that I didn't put a comment or note about it here.
Will add that.

@karfau karfau changed the title fix: Normalize white space characters and preserve references fix: Normalize white space characters and preserve references in attributes Aug 26, 2021
@brodycj
Copy link
Member

brodycj commented Aug 27, 2021

Thanks for raising ... and proposing a solution for #303.

But TBH I felt a bit surprised to see the solution for #303 kept in a separate PR due to multiple factors:

I got a couple of test snapshot errors when I merged these updates together with the updates proposed in PR #305, which I would consider to be a little bit of rapid snapshot churn.

Thoughts?

Am I too pedantic here?

Copy link
Member

@brodycj brodycj left a comment

Choose a reason for hiding this comment

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

  • I think we need to remove .only from a test in one place, guessing it was just an oversight - now fixed
  • suggesting to add some spaces & blank lines

Code changes look good overall, +1 (+100) for cleaning up & removing what looks like repeated regex replacements.

lib/sax.js Outdated Show resolved Hide resolved
lib/sax.js Outdated Show resolved Hide resolved
lib/sax.js Outdated Show resolved Hide resolved
test/dom/serializer.test.js Outdated Show resolved Hide resolved
test/dom/serializer.test.js Show resolved Hide resolved
test/parse/parse-element.test.js Show resolved Hide resolved
test/parse/parse-element.test.js Show resolved Hide resolved
test/parse/parse-element.test.js Outdated Show resolved Hide resolved
test/parse/parse-element.test.js Show resolved Hide resolved
@karfau
Copy link
Member Author

karfau commented Aug 27, 2021

Regarding .only, thx. I think we should add an eslint rule to prevent such things from slipping through.

Regarding the split of issues:

  1. All line breaks must have been normalized on input to #xA as described in 2.11 End-of-Line Handling, so the rest of this algorithm operates on text normalized in this way.

For me sounds more like like a prerequisite than a part of the algorithm. So I propose the I land the PR for line endinge normalization first. And then deal with the issues in this PR. Or even rebase this one on top of the other to see the impact right away.
I would still prefer to land them in two separate PRs, since they are separate sections in the specs.

Thx for going as as trying to merge them both.

@brodycj
Copy link
Member

brodycj commented Aug 27, 2021

Yeah I would favor landing PR #305 first. +1 for adding eslint rules to keep things like .only from slipping in. The Prettier project seems to have been using some nice eslint rules as well.

@karfau karfau force-pushed the 284-serialize-whitespace-literals-to-character-references branch from 6b3cdef to aa06c95 Compare August 27, 2021 14:48
@karfau karfau changed the base branch from master to normalize-line-endings August 27, 2021 20:51
@karfau karfau closed this Aug 27, 2021
@karfau karfau deleted the 284-serialize-whitespace-literals-to-character-references branch August 27, 2021 20:52
@karfau karfau restored the 284-serialize-whitespace-literals-to-character-references branch August 27, 2021 21:03
@karfau karfau reopened this Aug 27, 2021
@karfau
Copy link
Member Author

karfau commented Aug 27, 2021

Didn't mean to close the PR

@karfau karfau force-pushed the normalize-line-endings branch from 509085e to d5405e4 Compare August 28, 2021 03:22
@karfau karfau force-pushed the normalize-line-endings branch 2 times, most recently from 03b9fd1 to 4801a70 Compare August 28, 2021 03:51
@karfau karfau force-pushed the 284-serialize-whitespace-literals-to-character-references branch from aa06c95 to 5d32b43 Compare August 28, 2021 04:02
@karfau karfau changed the base branch from normalize-line-endings to master August 28, 2021 04:06
@karfau karfau force-pushed the 284-serialize-whitespace-literals-to-character-references branch from 95ffbab to acf094b Compare August 28, 2021 04:20
@karfau karfau changed the base branch from master to normalize-line-endings August 28, 2021 04:21
@karfau karfau force-pushed the normalize-line-endings branch from 02de7af to d2fb058 Compare August 28, 2021 05:57
@karfau karfau force-pushed the 284-serialize-whitespace-literals-to-character-references branch from acf094b to ae9c1ea Compare August 28, 2021 05:57
@karfau karfau deleted the branch xmldom:normalize-line-endings August 29, 2021 07:22
@karfau karfau closed this Aug 29, 2021
@karfau karfau deleted the 284-serialize-whitespace-literals-to-character-references branch August 29, 2021 07:26
@karfau
Copy link
Member Author

karfau commented Aug 29, 2021

Such a mess... the subsequent PR landing seems to only work when the branches are all in the same repository.
So I rebased and recreated the PR in #310

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect serialization of XML attributes containing white space
2 participants