Page MenuHomePhabricator

large_lines.diff

Authored By
epriestley
Oct 8 2015, 5:42 PM
Size
618 B
Referenced Files
None
Subscribers
None

large_lines.diff

diff --git a/src/utils/utils.php b/src/utils/utils.php
index 5e5f305..008d09d 100644
--- a/src/utils/utils.php
+++ b/src/utils/utils.php
@@ -770,6 +770,16 @@ function phutil_split_lines($corpus, $retain_endings = true) {
return array('');
}
+ $count = substr_count($corpus, "\n");
+ $limit = 1024 * 1024;
+ if ($count > $limit) {
+ throw new Exception(
+ pht(
+ 'Huge input! Found %s lines, hoped for %s.',
+ new PhutilNumber($count),
+ new Phutilnumber($limit)));
+ }
+
// Split on "\r\n" or "\n".
if ($retain_endings) {
$lines = preg_split('/(?<=\n)/', $corpus);

File Metadata

Mime Type
text/plain; charset=utf-8
Storage Engine
amazon-s3
Storage Format
Raw Data
Storage Handle
phabricator/kv/nl/u33vz5fk4bmuifll
Default Alt Text
large_lines.diff (618 B)

Event Timeline