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

Don't encode windows line-breaks with special characters. #211

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ function encodeSpecialCharactersInAttribute(attributeValue){

function encodeSpecialCharactersInText(text){
return text
.replace(/\r\n/g, '\n') // Line ending normalization (Note: this should normally be done by the xml parser). See: https://www.w3.org/TR/xml/#sec-line-ends
.replace(/([&<>\r])/g, function(str, item){
// Special character normalization. See:
// - https://www.w3.org/TR/xml-c14n#ProcessingModel (Text Nodes)
Expand Down
4 changes: 2 additions & 2 deletions test/canonicalization-unit-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,11 @@ module.exports = {
"<child><inner>12\n3\t</inner></child>")
},

"Exclusive canonicalization does not alter CR-NL (windows line separator) sequences": function(test){
"Exclusive canonicalization does alter CR-NL (windows line separator) sequences": function(test){
compare(test,
"<root><child><inner>123</inner>\r\n</child></root>",
"//*[local-name(.)='child']",
"<child><inner>123</inner>&#xD;\n</child>")
"<child><inner>123</inner>\n</child>")
},

"Exclusive canonicalization preserves and encodes CR white space": function(test){
Expand Down