Dave Jarvis' Repositories

git clone https://repo.autonoma.ca/repo/treetrek.git

Stops highlighting large files

Author Dave Jarvis <email>
Date 2026-02-15 01:15:34 GMT-0800
Commit f202d835b36da00fa349652b2d1b56848d3bf19f
Parent 33a9825
Delta 11 lines added, 3 lines removed, 8-line increase
pages/FilePage.php
class FilePage extends BasePage {
+ private const MAX_HIGHLIGHT_SIZE = 65536;
+ private const MAX_DISPLAY_SIZE = 524288;
+
private $currentRepo;
private $git;
if( !$file->renderMedia( $renderer, $rawUrl ) ) {
if( $file->isText() ) {
- if( $size > 524288 ) {
+ if( $size > self::MAX_DISPLAY_SIZE ) {
ob_start();
$file->renderSize( $renderer );
} );
- echo '<div class="blob-content"><pre class="blob-code">' .
- $file->highlight( $renderer, $content ) . '</pre></div>';
+ if( $size > self::MAX_HIGHLIGHT_SIZE ) {
+ echo '<div class="blob-content"><pre class="blob-code">' .
+ htmlspecialchars( $content ) . '</pre></div>';
+ } else {
+ echo '<div class="blob-content"><pre class="blob-code">' .
+ $file->highlight( $renderer, $content ) . '</pre></div>';
+ }
}
} else {