3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-15 12:30:06 +01:00
Paper/Spigot-Server-Patches/0151-Add-system-property-to-disable-book-size-limits.patch
2019-04-27 17:35:50 -04:00

62 Zeilen
2.9 KiB
Diff

From 8b8bf29963073a01cab38ed94ca062b0621fb85a Mon Sep 17 00:00:00 2001
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
index 0291ff194..49c93b75c 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java
@@ -36,6 +36,7 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta {
static final int MAX_PAGES = 50;
static final int MAX_PAGE_LENGTH = 320; // 256 limit + 64 characters to allow for psuedo colour codes
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;
@@ -192,7 +193,7 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta {
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;
}
@@ -228,7 +229,7 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta {
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]);
}
@@ -240,13 +241,13 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta {
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);
}
--
2.21.0