2020-05-06 11:48:49 +02:00
|
|
|
From 0000000000000000000000000000000000000000 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
|
2021-06-11 08:29:15 +02:00
|
|
|
index 65b6d32e3e1130a64df33082f3292cb1ce6f500a..1a4c1763e883e445433b3780fe20db7f62b780e8 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
|
2021-05-06 18:27:19 +02:00
|
|
|
@@ -41,6 +41,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;
|
2021-05-06 18:27:19 +02:00
|
|
|
@@ -243,7 +244,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;
|
|
|
|
}
|
|
|
|
|
2021-05-06 18:27:19 +02:00
|
|
|
@@ -440,7 +441,7 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta {
|
2021-01-01 05:03:19 +01:00
|
|
|
String validatePage(String page) {
|
|
|
|
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);
|
2017-05-14 03:26:19 +02:00
|
|
|
}
|
2021-01-01 05:03:19 +01:00
|
|
|
return page;
|
2021-05-06 18:27:19 +02:00
|
|
|
@@ -450,7 +451,7 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta {
|
2021-01-01 05:03:19 +01:00
|
|
|
// asserted: page != null
|
|
|
|
if (this.pages == null) {
|
|
|
|
this.pages = new ArrayList<String>();
|
|
|
|
- } else if (this.pages.size() >= MAX_PAGES) {
|
|
|
|
+ } else if (this.pages.size() >= MAX_PAGES && !OVERRIDE_CHECKS) {// Paper - Add override
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
this.pages.add(page);
|