Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-16 19:40:07 +01:00
4104545b11
"It was from a different time before books were as jank as they are now. As time has gone on they've only proven to be worse and worse."
54 Zeilen
2.9 KiB
Diff
54 Zeilen
2.9 KiB
Diff
From 0000000000000000000000000000000000000000 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.
|
|
|
|
Removed in 1.17: It was from a different time before books were as jank as they are now. As time has gone on they've only proven to be worse and worse.
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java
|
|
index a33dd184ea51df7e59ed08e5e2b0ea4ed9dadff5..1d94d285951faa98ff1f70c3c5330dfaa77cb691 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java
|
|
@@ -42,6 +42,7 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta {
|
|
static final int MAX_PAGES = 100;
|
|
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;
|
|
@@ -244,7 +245,7 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta {
|
|
if (title == null) {
|
|
this.title = null;
|
|
return true;
|
|
- } else if (title.length() > CraftMetaBook.MAX_TITLE_LENGTH) {
|
|
+ } else if (title.length() > CraftMetaBook.MAX_TITLE_LENGTH && !CraftMetaBook.OVERRIDE_CHECKS) { // Paper - Add override
|
|
return false;
|
|
}
|
|
|
|
@@ -441,7 +442,7 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta {
|
|
String validatePage(String page) {
|
|
if (page == null) {
|
|
page = "";
|
|
- } else if (page.length() > CraftMetaBook.MAX_PAGE_LENGTH) {
|
|
+ } else if (page.length() > CraftMetaBook.MAX_PAGE_LENGTH && !CraftMetaBook.OVERRIDE_CHECKS) { // Paper - Add override
|
|
page = page.substring(0, MAX_PAGE_LENGTH);
|
|
}
|
|
return page;
|
|
@@ -451,7 +452,7 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta {
|
|
// asserted: page != null
|
|
if (this.pages == null) {
|
|
this.pages = new ArrayList<String>();
|
|
- } else if (this.pages.size() >= CraftMetaBook.MAX_PAGES) {
|
|
+ } else if (this.pages.size() >= CraftMetaBook.MAX_PAGES && !CraftMetaBook.OVERRIDE_CHECKS) { // Paper - Add override
|
|
return;
|
|
}
|
|
this.pages.add(page);
|