Mojira Archive
MC-149792

Client book length mismatch resulting in crash

Editing (already once edited) books with colored content/'§' makes the client mismatch the actual character length, resulting in either one character too much (takes away another character) or too less (= § or following character still left) being deleted when removing characters.

Concrete steps to reproduce:

  • start a 1.13.2 client, create a new singleplayer world, copy and paste any text with '§' characters in a book (see below), save world
  • start a 1.14.x client, convert/open the world, open the book

Or use the following command in 1.14.x:

/setblock ~ ~ ~ oak_sign{Text1:"{\"text\":\"Click me\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/give @p writable_book{pages:[\\\"\\u00a7nVery cool text\\n\\u00a7r \\u00a7\\u00a7\\u00a7\\u00a7 hi\\n\\u00a75more\\n\\u00a7etext\\\"]}\"}}"}

What can be observed:

  • clicking on or marking the last character of the book -> crash
  • going to the last character with the right arrow doesn't go to the very end, but stops at a character before it
  • trying to remove characters where a '§' is results in seemingly the wrong character being removed
  • most notably: clicking the front on the second last line, then pressing the delete/backspace key removes characters a few letters behind the actually selected position

This means that on a click in lines containing '§' the position/character length is calculated wrongly

i.e. copy and paste

§nVery cool text
§r §§§§ hi

§5and even more
§etext

The older 1.14.3 crash log had a different stacktrace , this is the latest

1.15.2: crash-2020-04-28_15.38.46-client.txtjava.lang.StringIndexOutOfBoundsException: String index out of range: 44
	at java.base/java.lang.StringLatin1.charAt(StringLatin1.java:48)
	at java.base/java.lang.String.charAt(String.java:711)
	at dch.a(SourceFile:454)
	at dha.mouseClicked(SourceFile:779)
	at dbo.b(SourceFile:86)
	at dgb.wrapScreenError(SourceFile:447)
	at dbo.a(SourceFile:86)
	at dbo.c(SourceFile:150)
	at ais.execute(SourceFile:94)
	at dbo.b(SourceFile:150)
	at org.lwjgl.glfw.GLFWMouseButtonCallbackI.callback(GLFWMouseButtonCallbackI.java:36)
	at org.lwjgl.system.JNI.invokeV(Native Method)
	at org.lwjgl.glfw.GLFW.glfwPollEvents(GLFW.java:3101)
	at com.mojang.blaze3d.systems.RenderSystem.flipFrame(SourceFile:98)
	at cxx.e(SourceFile:301)
	at dbn.d(SourceFile:1012)
	at dbn.d(SourceFile:619)
	at net.minecraft.client.main.Main.main(SourceFile:204)