-
Notifications
You must be signed in to change notification settings - Fork 28
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
Escape end of line characters based on 'XML End-Of-Line Encoding' SEP. #349
Conversation
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.
LGTM
* | `YQ3ChSBiwoU=` | `'a\r\u0085 b\u0085'` | `'a
… b…'` | | ||
* | `YQ3igKggYsKFIGPigKg=` | `'a\r\u2028 b\u0085 c\u2028'` | `'a

 b… c
'` | | ||
*/ | ||
// FIXME ~ Unable to add "org.junit.jupiter:junit-jupiter-params" as a test dependency...classes do not resolve |
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.
comment
or you could just write your own quick loop, something like:
// list of (raw input, expected) pairs
val tests = listOf(
"\n \n" to "
 
",
...
)
tests.forEachIndexed { idx, test -> {
val writer = xmlStreamWriter(pretty = false)
writer.startTag("a")
writer.text(test.first)
writer.endTag("a")
val expected = "<a>${test.second}</a>"
assertEquals(expected, writer.toString(), "test case $idx failed")
}
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.
Yep, that's better I'll update before push.
@@ -59,7 +59,15 @@ class XmlPullSerializer(pretty: Boolean, private val serializer: XmlSerializer = | |||
} | |||
|
|||
override fun text(text: String): XmlStreamWriter { | |||
serializer.text(text) | |||
text.forEach { character -> |
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.
question
- It looks as though
serializer.text(...)
works as "append" if called multiple times? (own clarification) - Is there any performance consideration here?
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.
- Yes this is my understanding as well. I would expect unit tests to fail if this were not the case after the addition. Here is the library function that appends to the string.
- Yes. Optimistically perhaps not much of an impact as we're simply pulling the linear iteration on each character in the string from inside the xpp library into our code, but there may be things I'm missing. In any case I was unable to think of a cleaner or more performant way of implementing this due to the restrictions in the XPP interface itself. I think the way forward here is to move from XPP to our own implementation.
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.
sure sounds good. I sort of figured as much
Issue #, if available: #142
SEP: /reviews/CR-40585029/revisions/3
NOTE: This PR does not address linefeeds in attribute string values. Discussed this w/ SEP author and believe this needs to be implemented to conform to SEP. However the XPP API does not seem to offer a way of writing raw character values to attributes. So, in order to make this work I believe we'll have to move to another serialize that provides us more control.
Description of changes:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.