aboutsummaryrefslogtreecommitdiffstats
path: root/custom
diff options
context:
space:
mode:
authorHenrique Pimentel <66185935+HenriquerPimentel@users.noreply.github.com>2024-06-06 09:06:59 +0100
committerGitHub <noreply@github.com>2024-06-06 16:06:59 +0800
commitf7125ab61aaa02fd4c7ab0062a2dc9a57726e2ec (patch)
tree99a05104c9092e23f5d73ac4af702b2b80e862ae /custom
parent24dace8f76a8166d48203ed41fd1c3d66ace715c (diff)
downloadgitea-f7125ab61aaa02fd4c7ab0062a2dc9a57726e2ec.tar.gz
gitea-f7125ab61aaa02fd4c7ab0062a2dc9a57726e2ec.zip
Add `MAX_ROWS` option for CSV rendering (#30268)
This solution implements a new config variable MAX_ROWS, which corresponds to the “Maximum allowed rows to render CSV files. (0 for no limit)” and rewrites the Render function for CSV files in markup module. Now the render function only reads the file once, having MAX_FILE_SIZE+1 as a reader limit and MAX_ROWS as a row limit. When the file is larger than MAX_FILE_SIZE or has more rows than MAX_ROWS, it only renders until the limit, and displays a user-friendly warning informing that the rendered data is not complete, in the user's language. --- Previously, when a CSV file was larger than the limit, the render function lost its function to render the code. There were also multiple reads to the file, in order to determine its size and render or pre-render. The warning: ![image](https://s3.amazonaws.com/i.snag.gy/vcKh90.jpg)
Diffstat (limited to 'custom')
-rw-r--r--custom/conf/app.example.ini3
1 files changed, 3 insertions, 0 deletions
diff --git a/custom/conf/app.example.ini b/custom/conf/app.example.ini
index 7677168d83..e619aae729 100644
--- a/custom/conf/app.example.ini
+++ b/custom/conf/app.example.ini
@@ -1334,6 +1334,9 @@ LEVEL = Info
;;
;; Maximum allowed file size in bytes to render CSV files as table. (Set to 0 for no limit).
;MAX_FILE_SIZE = 524288
+;;
+;; Maximum allowed rows to render CSV files. (Set to 0 for no limit)
+;MAX_ROWS = 2500
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;