-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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 inconsistently add XML declarations #1227
Conversation
a8f60e5
to
6bfe764
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should also include a test that verifies the behavior we’re correcting (i.e., that an unwanted XML declaration is indeed added by the library).
I just noticed that the parser also collapses empty tags:
$ echo '<a></a>' | http --offline pie.dev/post content-type:application/xml
<?xml version="1.0" encoding="utf-8"?>
<a/>
And I assume that might not be the last unwanted alteration. Not sure if we should spend too much time trying to fix this.
(I was against reintroducing the XML formatter but was assured that this one has none the issues of the original one, but it seems like we’re in a similar situation.)
We already have such tests (we had tests that did not have a declaration in their raw version, but have it on their formatted. So I simply fixed them).
It is due to Python's parser is not really caring about roundtripability. I've looked around on PyPI, but I have not yet found an XML parser that claims to have a full-roundtripability feature. If that is what we are looking at, we could drop this or explicitly mention about the formatters are only support for semantical equivalence. |
Codecov Report
@@ Coverage Diff @@
## master #1227 +/- ##
==========================================
- Coverage 97.28% 96.72% -0.57%
==========================================
Files 67 81 +14
Lines 4235 5398 +1163
==========================================
+ Hits 4120 5221 +1101
- Misses 115 177 +62
Continue to review full report at Codecov.
|
cec2fd5
to
775716f
Compare
What I mean is that we implicitly rely on the library auto-adding the declaration. For example, we assume there’ll always be Let’s add an explicit test case verifying this assumption still holds (something like
Let’s do that. |
I see. I've changed it now to ensure there is at least one line and the first line is some sort of a declaration. If that is the case, we either get rid of it or replace it with the original version (if there are any).
Sure! |
f2c0ca7
to
19cbfda
Compare
19cbfda
to
7f4521b
Compare
Resolves #1156