Changeset View
Changeset View
Standalone View
Standalone View
src/applications/console/core/DarkConsoleCore.php
Show First 20 Lines • Show All 118 Lines • ▼ Show 20 Lines | private function sanitizeForJSON($data) { | ||||
} else if (is_array($data)) { | } else if (is_array($data)) { | ||||
foreach ($data as $key => $value) { | foreach ($data as $key => $value) { | ||||
$data[$key] = $this->sanitizeForJSON($value); | $data[$key] = $this->sanitizeForJSON($value); | ||||
} | } | ||||
return $data; | return $data; | ||||
} else if (is_resource($data)) { | } else if (is_resource($data)) { | ||||
return '<resource>'; | return '<resource>'; | ||||
} else { | } else { | ||||
// This is very probably not a string in strict sense | |||||
$data = phutil_string_cast($data); | |||||
valerio.bozzolan: Note that this comment from Evan somehow supports the above line:
https://secure.phabricator. | |||||
// Truncate huge strings. Since the data doesn't really matter much, | // Truncate huge strings. Since the data doesn't really matter much, | ||||
// just truncate bytes to avoid PhutilUTF8StringTruncator overhead. | // just truncate bytes to avoid PhutilUTF8StringTruncator overhead. | ||||
$length = strlen($data); | $length = strlen($data); | ||||
$max = 4096; | $max = 4096; | ||||
if ($length > $max) { | if ($length > $max) { | ||||
$data = substr($data, 0, $max).'...<'.$length.' bytes>...'; | $data = substr($data, 0, $max).'...<'.$length.' bytes>...'; | ||||
} | } | ||||
return phutil_utf8ize($data); | return phutil_utf8ize($data); | ||||
} | } | ||||
} | } | ||||
} | } |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0
Note that this comment from Evan somehow supports the above line:
https://secure.phabricator.com/T13588#257338