@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Disable default syntax highlighting for large files in DocumentEngine

Summary: Ref T13105. See also T7895. When users render very large files as source via DocumentEngine, skip highlighting.

Test Plan: Fiddled with the limit, viewed files, saw highlighting degrade.

Reviewers: mydeveloperday

Reviewed By: mydeveloperday

Maniphest Tasks: T13105

Differential Revision: https://secure.phabricator.com/D19306

+17 -4
+17 -4
src/applications/files/document/PhabricatorSourceDocumentEngine.php
··· 24 24 protected function newDocumentContent(PhabricatorDocumentRef $ref) { 25 25 $content = $this->loadTextData($ref); 26 26 27 + $messages = array(); 28 + 27 29 $highlighting = $this->getHighlightingConfiguration(); 28 30 if ($highlighting !== null) { 29 31 $content = PhabricatorSyntaxHighlighter::highlightWithLanguage( 30 32 $highlighting, 31 33 $content); 32 34 } else { 33 - $content = PhabricatorSyntaxHighlighter::highlightWithFilename( 34 - $ref->getName(), 35 - $content); 35 + $highlight_limit = DifferentialChangesetParser::HIGHLIGHT_BYTE_LIMIT; 36 + if (strlen($content) > $highlight_limit) { 37 + $messages[] = $this->newMessage( 38 + pht( 39 + 'This file is larger than %s, so syntax highlighting was skipped.', 40 + phutil_format_bytes($highlight_limit))); 41 + } else { 42 + $content = PhabricatorSyntaxHighlighter::highlightWithFilename( 43 + $ref->getName(), 44 + $content); 45 + } 36 46 } 37 47 38 - return $this->newTextDocumentContent($content); 48 + return array( 49 + $messages, 50 + $this->newTextDocumentContent($content), 51 + ); 39 52 } 40 53 41 54 }