#764 Fix crash on parse some control chars#771
Conversation
detekt issues fix
| """.trimIndent() | ||
|
|
||
| parseAllSuitesXml(crashingAllSuitesMessage) | ||
| parseOneSuiteXml(crashingOneSuiteMessage) |
There was a problem hiding this comment.
should we also assert that the parsed value matches the expected value? Currently this test will pass as long as parsing doesn't fail. We probably want to assert <failure>... is decoded correctly as well.
There was a problem hiding this comment.
You have right, Im add asserts and split tests to two. One for one suite and one for all suites
Add asserts in test and replace Files.readString to Files.readAllBytes for compability with java 1.8
| private fun xmlText(path: Path): String { | ||
| if (!path.toFile().exists()) throw RuntimeException("$path doesn't exist!") | ||
| return Files.readAllBytes(path) | ||
| return String(Files.readAllBytes(path)) |
| import org.apache.commons.text.StringEscapeUtils | ||
|
|
||
| fun fixHtmlCodes(data: String): String { | ||
| val isoHtmlCodesToReplace = listOf(0x00..0x1F).union(listOf(0x7F..0x9F)).flatten() |
There was a problem hiding this comment.
Is there some document we can reference in a comment about where these magic numbers come from?
There was a problem hiding this comment.
The other thought I had is, are we sure there's no helper already defined in a library that does what we need? Maybe this is a special case so the custom code is justified.
There was a problem hiding this comment.
I this case we need to get list of control chars and convert them to html codes with avoid white chars. I cant find method doing this.
About magic numbers: Im added enum with I hope intuitive names. Enum on the top has comment about destination and link to utf-8 table to prove my idea.
| </testsuites> | ||
| """.trimIndent() | ||
| val oneSuiteXml = parseOneSuiteXml(crashingOneSuiteMessage).xmlToString().trimIndent() | ||
| Assert.assertEquals("One Suite Messages should be the same!", expectedOneSuiteMessage, oneSuiteXml) |
There was a problem hiding this comment.
The tests look great! Thanks for updating these.
detekt issues fix
Add asserts in test and replace Files.readString to Files.readAllBytes for compability with java 1.8
|
|
||
| import org.apache.commons.text.StringEscapeUtils | ||
|
|
||
| fun fixHtmlCodes(data: String): String { |
There was a problem hiding this comment.
IMO expressions > blocks ;)
fun fixHtmlCodes(data: String): String = listOf(
UtfControlCharRanges.CONTROL_TOP_START.charValue..UtfControlCharRanges.CONTROL_TOP_END.charValue,
UtfControlCharRanges.CONTROL_BOTTOM_START.charValue..UtfControlCharRanges.CONTROL_BOTTOM_END.charValue
).flatten()
.map { StringEscapeUtils.escapeXml11(it.toChar().toString()) }
.filter { it.startsWith("&#") }
.fold(data) { fixedStr: String, isoControlCode: String -> fixedStr.replace(isoControlCode, "") }
unions are not mandatory for those values
There was a problem hiding this comment.
I am also for @jan-gogo version 👍
There was a problem hiding this comment.
Thanks! Changed to better version :)
| // https://github.com/mockk/mockk | ||
| const val MOCKK = "1.9.3" | ||
|
|
||
| const val COMMON_TEXT = "1.7" |
There was a problem hiding this comment.
Please, add here link to repo or equivalent, thanks.
pawelpasterz
left a comment
There was a problem hiding this comment.
Please remove should_exists.txt file from PR.
For the future PRs, let's rebase branch once new commits have appeared in master. I think it's good to have PR up-to-date with master in general. It could be just me but in you PR i see also code from @jan-gogo PR a that was a bit confusing.
Anyway, thanks!
* Fail fast when results-dir is incorrect
detekt issues fix
Add asserts in test and replace Files.readString to Files.readAllBytes for compability with java 1.8
remove should_exists
df19d79
Removed :) |
|
@adamfilipow92 |
* #764 Fix crash on parse some control chars * #764 detekt issues fix detekt issues fix * Asserts in tests Add asserts in test and replace Files.readString to Files.readAllBytes for compability with java 1.8 * Add documentation of magicial numers * set name of UtfControlChars enum to UtfControlCharRanges * #764 Fix crash on parse some control chars * #764 detekt issues fix detekt issues fix * Asserts in tests Add asserts in test and replace Files.readString to Files.readAllBytes for compability with java 1.8 * Add documentation of magicial numers * set name of UtfControlChars enum to UtfControlCharRanges * Detekt suggestions * Create should_exists.txt * #764 Fix crash on parse some control chars * #764 detekt issues fix detekt issues fix * Asserts in tests Add asserts in test and replace Files.readString to Files.readAllBytes for compability with java 1.8 * Add documentation of magicial numers * set name of UtfControlChars enum to UtfControlCharRanges * Fail fast when results-dir is incorrect (#772) * Fail fast when results-dir is incorrect * #764 Change XmlPreprocessor more functional and remove should_exists * Add info about issue to release notes Co-authored-by: Adam <adam.filipowicz92@gmail.com> Co-authored-by: Jan Góral <60390247+jan-gogo@users.noreply.github.com>
Fixes #764
Fix crash on parse some control chars