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: XML whitespace trims while pretty print #2415

Merged

Conversation

bharath2203
Copy link

@bharath2203 bharath2203 commented Oct 10, 2023

Description

The above PR resolves the bug which causes the XML element with whitespace in the left or right to be trimmed after passing the variable through karate.log or print.

The idea of the fix is to clone a temporary node while serializing the XML node to string in case of pretty print, as the code trims the whitespace of the element while pretty printing and does that directly on the object itself causing it to change.

Issue: #2385

Screenshots of failing test cases before the changes:
Screenshot 2023-10-10 at 8 32 49 PM

Thanks for contributing to this Pull Request. Make sure that you submit this Pull Request against the develop branch of this repository, add a brief description, and tag the relevant issue(s) and PR(s) below.

@ptrthomas ptrthomas merged commit b1145b1 into karatelabs:develop Oct 11, 2023
1 check passed
@bouncysteve
Copy link

Thanks for the work on this. I can see that the act of logging will not change the xml. I do think though that the pretty printing should preserve the whitespace within an xml element value, as it is significant. What you see in the log would not be the correct element value when the whitespace has been stripped. In XmlUtilsTest line 238 the expected value should be:

  • " moo \n"

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

Successfully merging this pull request may close these issues.

3 participants