bluepill icon indicating copy to clipboard operation
bluepill copied to clipboard

Fix #125 invalid character (backspace) in output

Open pschneider opened this issue 6 years ago • 7 comments

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.

pschneider avatar Jan 07 '18 20:01 pschneider

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...

pschneider avatar Jan 07 '18 20:01 pschneider

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])];

pschneider avatar Jan 07 '18 20:01 pschneider

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

oliverhu avatar Jan 08 '18 00:01 oliverhu

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.

mbalex avatar Jan 10 '18 12:01 mbalex

/azp run

jmkk avatar May 23 '19 20:05 jmkk

Pull request contains merge conflicts.

azure-pipelines[bot] avatar May 23 '19 20:05 azure-pipelines[bot]

Is this still an issue?

chenxiao0228 avatar Mar 24 '20 16:03 chenxiao0228