mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-29 10:57:44 +09:00 
			
		
		
		
	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: 
This commit is contained in:
		
				
					committed by
					
						 GitHub
						GitHub
					
				
			
			
				
	
			
			
			
						parent
						
							24dace8f76
						
					
				
				
					commit
					f7125ab61a
				
			| @@ -52,6 +52,7 @@ var UI = struct { | ||||
|  | ||||
| 	CSV struct { | ||||
| 		MaxFileSize int64 | ||||
| 		MaxRows     int | ||||
| 	} `ini:"ui.csv"` | ||||
|  | ||||
| 	Admin struct { | ||||
| @@ -107,8 +108,10 @@ var UI = struct { | ||||
| 	}, | ||||
| 	CSV: struct { | ||||
| 		MaxFileSize int64 | ||||
| 		MaxRows     int | ||||
| 	}{ | ||||
| 		MaxFileSize: 524288, | ||||
| 		MaxRows:     2500, | ||||
| 	}, | ||||
| 	Admin: struct { | ||||
| 		UserPagingNum   int | ||||
|   | ||||
		Reference in New Issue
	
	Block a user