mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-18 11:54:59 -04:00
chat component: allow unescaped control characters (e.g. \n in json string)
The Cuberite kick message is now properly parsed
This commit is contained in:
parent
a216230e02
commit
224d5b87e2
@ -14,6 +14,7 @@
|
|||||||
package de.bixilon.minosoft.util.json
|
package de.bixilon.minosoft.util.json
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonParser
|
import com.fasterxml.jackson.core.JsonParser
|
||||||
|
import com.fasterxml.jackson.core.json.JsonReadFeature
|
||||||
import com.fasterxml.jackson.databind.DeserializationFeature
|
import com.fasterxml.jackson.databind.DeserializationFeature
|
||||||
import com.fasterxml.jackson.databind.MapperFeature
|
import com.fasterxml.jackson.databind.MapperFeature
|
||||||
import com.fasterxml.jackson.databind.PropertyNamingStrategies
|
import com.fasterxml.jackson.databind.PropertyNamingStrategies
|
||||||
@ -31,6 +32,7 @@ object Jackson {
|
|||||||
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
|
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
|
||||||
.disable(JsonParser.Feature.AUTO_CLOSE_SOURCE)
|
.disable(JsonParser.Feature.AUTO_CLOSE_SOURCE)
|
||||||
.enable(MapperFeature.ACCEPT_CASE_INSENSITIVE_ENUMS)
|
.enable(MapperFeature.ACCEPT_CASE_INSENSITIVE_ENUMS)
|
||||||
|
.enable(JsonReadFeature.ALLOW_UNESCAPED_CONTROL_CHARS)
|
||||||
.build()
|
.build()
|
||||||
.registerModule(
|
.registerModule(
|
||||||
KotlinModule.Builder()
|
KotlinModule.Builder()
|
||||||
|
@ -227,6 +227,13 @@ internal class ChatComponentTest {
|
|||||||
assertEquals(expected, component)
|
assertEquals(expected, component)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `JSON not escaped new line`() {
|
||||||
|
val text = ChatComponent.of("""{"text":"Unsupported protocol version 762.""" + "\n" + """Try connecting with Minecraft 1.8.x-1.12.x"}""")
|
||||||
|
val expected = TextComponent("Unsupported protocol version 762.\nTry connecting with Minecraft 1.8.x-1.12.x")
|
||||||
|
assertEquals(text, expected)
|
||||||
|
}
|
||||||
|
|
||||||
private fun assertEquals(expected: ChatComponent, actual: ChatComponent) {
|
private fun assertEquals(expected: ChatComponent, actual: ChatComponent) {
|
||||||
when (expected) {
|
when (expected) {
|
||||||
is BaseComponent -> {
|
is BaseComponent -> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user