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

Prevent double encoding of 
 
 	 characters #27

Closed
wants to merge 1 commit into from

Conversation

neilcampbell
Copy link

@neilcampbell neilcampbell commented Jun 22, 2020

Fixes #26

Type of change:

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

@codecov-commenter
Copy link

codecov-commenter commented Jun 22, 2020

Codecov Report

Merging #27 into master will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master      #27   +/-   ##
=======================================
  Coverage   99.21%   99.21%           
=======================================
  Files          17       17           
  Lines        1902     1902           
  Branches      503      503           
=======================================
  Hits         1887     1887           
  Misses         15       15           
Impacted Files Coverage Δ
src/builder/XMLBuilderCBImpl.ts 98.70% <100.00%> (ø)
src/writers/BaseWriter.ts 97.46% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 79ebd77...6a954e1. Read the comment docs.

@oozcitak
Copy link
Owner

oozcitak commented Jun 22, 2020

Thank you for the PR. There are only five special characters defined in the XML Spec: > < & " '. So this library limits itself to those five.

I am fine with xmlbuilder2 being used in other markup languages. But in that case, I would prefer such additional functionality to be provided by adding flags or custom functions instead of changing base behavior. In that case, that would be custom text and attribute serialization functions that would be passed to the end function. Or maybe a flag that would change serialization behavior when set.

Also please see: #17
Custom functions in old xmlbuilder: https://github.com/oozcitak/xmlbuilder-js/wiki/Value-Conversion#textescape-functionstr

@neilcampbell
Copy link
Author

@oozcitak I'm using it to build xml, however the xml I am generating needs to exactly match a format produced by a different xml library in a different language. I think I'll just regex replace the xmlbuilder2 output, as currently there is no way for me to add encoded new line characters in attribute values without double encoding happening.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

encoded \r \n \t are being double encoded
3 participants