2020-01-22 03:02:07 +01:00
|
|
|
From 7fc537457526e08f359c64b2321cf1655f7f8295 Mon Sep 17 00:00:00 2001
|
2017-05-14 03:26:19 +02:00
|
|
|
From: Zach Brown <zach.brown@destroystokyo.com>
|
|
|
|
Date: Sat, 13 May 2017 20:11:21 -0500
|
|
|
|
Subject: [PATCH] Add system property to disable book size limits
|
|
|
|
|
|
|
|
If anyone comes in with a watchdog crash related to books after this patch
|
|
|
|
you will not only be publicly shamed but also made an example of.
|
|
|
|
|
|
|
|
Disables the security limits on books entirely, allowing plugins AND players
|
|
|
|
to make books with as much data as they want. Do not use this without
|
|
|
|
limiting incoming data from packets in some other way.
|
|
|
|
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java
|
2020-01-22 03:02:07 +01:00
|
|
|
index 08f3a315f..6ddb13358 100644
|
2017-05-14 03:26:19 +02:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java
|
2019-04-27 08:26:04 +02:00
|
|
|
@@ -36,6 +36,7 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta {
|
2019-07-23 21:17:32 +02:00
|
|
|
static final int MAX_PAGES = 100;
|
2017-05-14 03:37:46 +02:00
|
|
|
static final int MAX_PAGE_LENGTH = 320; // 256 limit + 64 characters to allow for psuedo colour codes
|
2017-05-14 03:26:19 +02:00
|
|
|
static final int MAX_TITLE_LENGTH = 32;
|
|
|
|
+ private static final boolean OVERRIDE_CHECKS = Boolean.getBoolean("disable.book-limits"); // Paper - Add override
|
|
|
|
|
|
|
|
protected String title;
|
|
|
|
protected String author;
|
2019-05-06 04:58:04 +02:00
|
|
|
@@ -198,7 +199,7 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta {
|
2017-05-14 03:26:19 +02:00
|
|
|
if (title == null) {
|
|
|
|
this.title = null;
|
|
|
|
return true;
|
|
|
|
- } else if (title.length() > MAX_TITLE_LENGTH) {
|
|
|
|
+ } else if (title.length() > MAX_TITLE_LENGTH && !OVERRIDE_CHECKS) { // Paper - Add override
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-05-06 04:58:04 +02:00
|
|
|
@@ -238,7 +239,7 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta {
|
2017-05-14 03:26:19 +02:00
|
|
|
throw new IllegalArgumentException("Invalid page number " + page + "/" + pages.size());
|
|
|
|
}
|
|
|
|
|
|
|
|
- String newText = text == null ? "" : text.length() > MAX_PAGE_LENGTH ? text.substring(0, MAX_PAGE_LENGTH) : text;
|
|
|
|
+ String newText = text == null ? "" : text.length() > MAX_PAGE_LENGTH && !OVERRIDE_CHECKS ? text.substring(0, MAX_PAGE_LENGTH) : text;
|
|
|
|
pages.set(page - 1, CraftChatMessage.fromString(newText, true)[0]);
|
|
|
|
}
|
|
|
|
|
2019-05-06 04:58:04 +02:00
|
|
|
@@ -252,13 +253,13 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta {
|
|
|
|
@Override
|
2017-05-14 03:26:19 +02:00
|
|
|
public void addPage(final String... pages) {
|
|
|
|
for (String page : pages) {
|
|
|
|
- if (this.pages.size() >= MAX_PAGES) {
|
|
|
|
+ if (this.pages.size() >= MAX_PAGES && !OVERRIDE_CHECKS) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (page == null) {
|
|
|
|
page = "";
|
|
|
|
- } else if (page.length() > MAX_PAGE_LENGTH) {
|
|
|
|
+ } else if (page.length() > MAX_PAGE_LENGTH && !OVERRIDE_CHECKS) { // Paper - Add override
|
|
|
|
page = page.substring(0, MAX_PAGE_LENGTH);
|
|
|
|
}
|
|
|
|
|
|
|
|
--
|
2020-01-22 03:02:07 +01:00
|
|
|
2.25.0.windows.1
|
2017-05-14 03:26:19 +02:00
|
|
|
|