Page MenuHomePhabricator
Paste P1863

large_lines.diff
ActivePublic

Authored by epriestley on Oct 8 2015, 5:42 PM.
Tags
None
Referenced Files
F868532: large_lines.diff
Oct 8 2015, 5:47 PM
F868530: large_lines.diff
Oct 8 2015, 5:46 PM
F868526: large_lines.diff
Oct 8 2015, 5:42 PM
F868525: large_lines.diff
Oct 8 2015, 5:42 PM
Subscribers
None
diff --git a/src/utils/utils.php b/src/utils/utils.php
index 5e5f305..4854681 100644
--- a/src/utils/utils.php
+++ b/src/utils/utils.php
@@ -770,6 +770,19 @@ function phutil_split_lines($corpus, $retain_endings = true) {
return array('');
}
+ $count = substr_count($corpus, "\n");
+ $limit = 1024 * 1024;
+ if ($count > $limit) {
+ $ex = new Exception(
+ pht(
+ 'Huge input! Found %s lines, hoped for %s. Probably about to '.
+ 'OOM. Exciting! Corpus begins: %s...',
+ new PhutilNumber($count),
+ new Phutilnumber($limit),
+ tsprintf("%s", substr($corpus, 0, 256))));
+ phlog($ex);
+ }
+
// Split on "\r\n" or "\n".
if ($retain_endings) {
$lines = preg_split('/(?<=\n)/', $corpus);

Event Timeline

epriestley changed the title of this paste from untitled to large_lines.diff.
epriestley updated the paste's language from autodetect to autodetect.
epriestley edited the content of this paste. (Show Details)
epriestley edited the content of this paste. (Show Details)