From 319735db3aa871a65e425ace6fc301748c6845e8 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Tue, 12 Sep 2017 22:18:16 +0100 Subject: [PATCH 1/5] Add support for quoting command arguments Un-escape quotes in inputted strings --- src/pocketmine/command/SimpleCommandMap.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pocketmine/command/SimpleCommandMap.php b/src/pocketmine/command/SimpleCommandMap.php index 352d93d3d..1587344a1 100644 --- a/src/pocketmine/command/SimpleCommandMap.php +++ b/src/pocketmine/command/SimpleCommandMap.php @@ -223,7 +223,7 @@ class SimpleCommandMap implements CommandMap{ } public function dispatch(CommandSender $sender, string $commandLine) : bool{ - $args = explode(" ", $commandLine); + $args = array_map("stripslashes", str_getcsv($commandLine, " ")); $sentCommandLabel = ""; $target = $this->matchCommand($sentCommandLabel, $args); From 8b33f711d00862c3eacc94e51b1294b37805081c Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Tue, 12 Sep 2017 22:19:02 +0100 Subject: [PATCH 2/5] Allow spaces in player names --- src/pocketmine/Player.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index 3e07ebaea..b91fc5c8f 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -184,7 +184,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ public static function isValidUserName(string $name) : bool{ $lname = strtolower($name); $len = strlen($name); - return $lname !== "rcon" and $lname !== "console" and $len >= 1 and $len <= 16 and preg_match("/[^A-Za-z0-9_]/", $name) === 0; + return $lname !== "rcon" and $lname !== "console" and $len >= 1 and $len <= 16 and preg_match("/[^A-Za-z0-9_ ]/", $name) === 0; } /** From ad72fe62328cd173d305204e1c03569131a171bd Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Thu, 14 Sep 2017 10:41:53 +0100 Subject: [PATCH 3/5] Make use of awesome new pack() codes for floats --- src/pocketmine/utils/Binary.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/pocketmine/utils/Binary.php b/src/pocketmine/utils/Binary.php index 6ae9ce3a5..9b3c8c547 100644 --- a/src/pocketmine/utils/Binary.php +++ b/src/pocketmine/utils/Binary.php @@ -285,7 +285,7 @@ class Binary{ */ public static function readFloat(string $str) : float{ self::checkLength($str, 4); - return (ENDIANNESS === self::BIG_ENDIAN ? unpack("f", $str)[1] : unpack("f", strrev($str))[1]); + return unpack("G", $str)[1]; } /** @@ -307,7 +307,7 @@ class Binary{ * @return string */ public static function writeFloat(float $value) : string{ - return ENDIANNESS === self::BIG_ENDIAN ? pack("f", $value) : strrev(pack("f", $value)); + return pack("G", $value); } /** @@ -318,7 +318,7 @@ class Binary{ */ public static function readLFloat(string $str) : float{ self::checkLength($str, 4); - return (ENDIANNESS === self::BIG_ENDIAN ? unpack("f", strrev($str))[1] : unpack("f", $str)[1]); + return unpack("g", $str)[1]; } /** @@ -340,7 +340,7 @@ class Binary{ * @return string */ public static function writeLFloat(float $value) : string{ - return ENDIANNESS === self::BIG_ENDIAN ? strrev(pack("f", $value)) : pack("f", $value); + return pack("g", $value); } /** @@ -361,7 +361,7 @@ class Binary{ */ public static function readDouble(string $str) : float{ self::checkLength($str, 8); - return ENDIANNESS === self::BIG_ENDIAN ? unpack("d", $str)[1] : unpack("d", strrev($str))[1]; + return unpack("E", $str)[1]; } /** @@ -371,7 +371,7 @@ class Binary{ * @return string */ public static function writeDouble(float $value) : string{ - return ENDIANNESS === self::BIG_ENDIAN ? pack("d", $value) : strrev(pack("d", $value)); + return pack("E", $value); } /** @@ -382,7 +382,7 @@ class Binary{ */ public static function readLDouble(string $str) : float{ self::checkLength($str, 8); - return ENDIANNESS === self::BIG_ENDIAN ? unpack("d", strrev($str))[1] : unpack("d", $str)[1]; + return unpack("e", $str)[1]; } /** @@ -391,7 +391,7 @@ class Binary{ * @return string */ public static function writeLDouble(float $value) : string{ - return ENDIANNESS === self::BIG_ENDIAN ? strrev(pack("d", $value)) : pack("d", $value); + return pack("e", $value); } /** From 53e5db514256f3e7261a43a8f53c9c2b415cca3d Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Thu, 14 Sep 2017 10:58:46 +0100 Subject: [PATCH 4/5] Updated PreProcessor submodule --- tests/preprocessor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/preprocessor b/tests/preprocessor index 868a61e57..c91e07daa 160000 --- a/tests/preprocessor +++ b/tests/preprocessor @@ -1 +1 @@ -Subproject commit 868a61e579f0d6e69f354a0fb5914dba7e92d084 +Subproject commit c91e07daa171bb8256eb7efe7d36143bfb565f4d From 4d1daecd9136b8969e2e7f8b0b32bd7cb409955d Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Thu, 14 Sep 2017 11:01:47 +0100 Subject: [PATCH 5/5] oops! --- tests/preprocessor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/preprocessor b/tests/preprocessor index c91e07daa..e0de63951 160000 --- a/tests/preprocessor +++ b/tests/preprocessor @@ -1 +1 @@ -Subproject commit c91e07daa171bb8256eb7efe7d36143bfb565f4d +Subproject commit e0de63951361c99d08124ef2fe1462252aeeffcb