-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* #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 <[email protected]> Co-authored-by: Jan Góral <[email protected]>
- Loading branch information
1 parent
5f0158c
commit 3936016
Showing
7 changed files
with
115 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
test_runner/src/main/kotlin/ftl/reports/xml/preprocesor/UtfControlCharRanges.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package ftl.reports.xml.preprocesor | ||
|
||
/** | ||
* Numbers come from ascii table https://www.utf8-chartable.de. | ||
* and represents control chars. We need to avoid characters in ranges CONTROL_TOP_START..CONTROL_TOP_END and | ||
* CONTROL_BOTTOM_START..CONTROL_BOTTOM_END because chars from that range escaped to html causing parsing errors. | ||
* */ | ||
enum class UtfControlCharRanges(val charValue: Int) { | ||
CONTROL_TOP_START(0x00), | ||
CONTROL_TOP_END(0x1F), | ||
CONTROL_BOTTOM_START(0x7F), | ||
CONTROL_BOTTOM_END(0x9F) | ||
} |
11 changes: 11 additions & 0 deletions
11
test_runner/src/main/kotlin/ftl/reports/xml/preprocesor/XmlPreprocessor.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package ftl.reports.xml.preprocesor | ||
|
||
import org.apache.commons.text.StringEscapeUtils | ||
|
||
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, "") } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters