From 827e836c4d28496a0f8c917a4980fe0f0d7d694b Mon Sep 17 00:00:00 2001 From: ghost Date: Thu, 15 Feb 2024 00:58:48 +0200 Subject: [PATCH] improve base 64 detection --- src/Manticore.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Manticore.php b/src/Manticore.php index 7116177..e12bd85 100644 --- a/src/Manticore.php +++ b/src/Manticore.php @@ -339,13 +339,13 @@ class Manticore case is_string($value) && false === mb_detect_encoding($value, null, true): return self::TYPE_BIN; - case is_string($value) && base64_encode((string) base64_decode($value, true)) === $value: + case is_string($value) && preg_match('/[^\s]{128,}/', $value) && base64_encode((string) base64_decode($value, true)) === $value: return self::TYPE_BASE_64; case is_string($value) && !is_numeric($value) && json_encode(json_decode($value)) === $value: return self::TYPE_JSON; - case is_string($value) && 1 === preg_match('/<\/[^>]+>/', $value): + case is_string($value) && preg_match('/<\/[^>]+>/', $value): return self::TYPE_XML; default: