From 2eb73619d1c45eb0ec1efc3dc310c1ab98422b75 Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 18 Jun 2015 13:05:32 -0700 Subject: [PATCH] Truncate large strings in DarkConsole Summary: Ref T8597. If a page issues a large query (like inserting a blob into file storage), we may try to utf8ize the entire thing. This is slow and pointless. Instead, truncate tab data after 4096 bytes before sanitizing. Test Plan: Adjusted limit to 256 bytes, saw long queries get truncated reasonably. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T8597 Differential Revision: https://secure.phabricator.com/D13347 --- src/applications/console/core/DarkConsoleCore.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/applications/console/core/DarkConsoleCore.php b/src/applications/console/core/DarkConsoleCore.php index 6696eb453f..09398df73a 100644 --- a/src/applications/console/core/DarkConsoleCore.php +++ b/src/applications/console/core/DarkConsoleCore.php @@ -127,6 +127,13 @@ final class DarkConsoleCore extends Phobject { } return $data; } else { + // Truncate huge strings. Since the data doesn't really matter much, + // just truncate bytes to avoid PhutilUTF8StringTruncator overhead. + $length = strlen($data); + $max = 4096; + if ($length > $max) { + $data = substr($data, 0, $max).'...<'.$length.' bytes>...'; + } return phutil_utf8ize($data); } } -- 2.51.2