bluepill
bluepill copied to clipboard
Fix #125 invalid character (backspace) in output
If you clear text in a UITest by pressing backspace, Xcode logs output into console with the UTF-8 character \x08
.
This results into the following error message when parsing JUnit output:
org.dom4j.DocumentException: Error on line 496 of document : An invalid XML character (Unicode: 0x8) was found in the element content of the document. Nested exception: An invalid XML character (Unicode: 0x8) was found in the element content of the document.
To fix this, I’ve replaced the character with the HTML Entity counterpart:
t = 10.54s Type '' into "TestTextField" TextField
This fixes #125.
As I didn’t write any production Objective-C code yet as I started with Swift only please let me know if there’s anything I can improve or needs to be changed.
I couldn’t find any specific unit test for this method to adjust. If there is any I would try to make it test my change. Otherwise I could also provide an XML file with one test case where this specific problem occurs.
Just ran the change on our CI and it looks like it still reports the error even though the XML file only contains the HTML entities. Will check why...
So it looks like even though the XML contains only the HTML entities, it's not possible to parse the file. Replacing the backspace characters \x08
with an empty string seems to work just fine.
Should we go with this solution?
[string replaceOccurrencesOfString:@"\x08" withString:@"" options:NSLiteralSearch range:NSMakeRange(0, [string length])];
replace \x08 with empty string doesn't sounds good. how about replace \x08 with \\x08. To add a unit test, check https://github.com/linkedin/bluepill/blob/master/Bluepill-cli/BPInstanceTests/BPTreeParserTests.m
we have the same issue, so I search a bit and found this: https://en.wikipedia.org/wiki/Valid_characters_in_XML https://stackoverflow.com/questions/397250/unicode-regex-invalid-xml-characters
valid characters are [\u0009\u000a\u000d\u0020-\uD7FF\uE000-\uFFFD]
I would propose to go through each character, and if you find them not being valid (see regex) then replace them with their escaped value as olverhu suggested for the \x08 case.
/azp run
Pull request contains merge conflicts.
Is this still an issue?