feat: extract simple_html_dom max_file_size to config (#4395)

This commit is contained in:
Dag 2025-01-04 19:43:48 +01:00 committed by GitHub
parent 48cb7d71ed
commit 1d02214e12
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 12 additions and 13 deletions

View file

@ -1,12 +1,5 @@
<?php <?php
/**
* RssBridgeYoutube
* Returns the newest videos
* WARNING: to parse big playlists (over ~90 videos), you need to edit simple_html_dom.php:
* change: define('MAX_FILE_SIZE', 600000);
* into: define('MAX_FILE_SIZE', 900000); (or more)
*/
class YoutubeBridge extends BridgeAbstract class YoutubeBridge extends BridgeAbstract
{ {
const NAME = 'YouTube Bridge'; const NAME = 'YouTube Bridge';

View file

@ -46,7 +46,11 @@ enable_debug_mode = false
; Whether to enable maintenance mode. If enabled, feed requests receive 503 Service Unavailable ; Whether to enable maintenance mode. If enabled, feed requests receive 503 Service Unavailable
enable_maintenance_mode = false enable_maintenance_mode = false
; Max file size for simple_html_dom in bytes (10000000 => 10 MB)
max_file_size = 10000000
[http] [http]
; Operation timeout in seconds ; Operation timeout in seconds
timeout = 15 timeout = 15
@ -70,6 +74,7 @@ type = "file"
custom_timeout = false custom_timeout = false
[admin] [admin]
; Advertise an email address where people can reach the administrator. ; Advertise an email address where people can reach the administrator.
; This address is displayed on the main page, visible to everyone! ; This address is displayed on the main page, visible to everyone!
; "" = Disabled (default) ; "" = Disabled (default)
@ -86,6 +91,7 @@ telegram = ""
donations = true donations = true
[proxy] [proxy]
; The HTTP proxy to tunnel requests through ; The HTTP proxy to tunnel requests through
; https://curl.se/libcurl/c/CURLOPT_PROXY.html ; https://curl.se/libcurl/c/CURLOPT_PROXY.html
; "" = Proxy disabled (default) ; "" = Proxy disabled (default)
@ -135,6 +141,7 @@ report_limit = 1
; --- Cache specific configuration --------------------------------------------- ; --- Cache specific configuration ---------------------------------------------
[FileCache] [FileCache]
; The root folder to store files in. ; The root folder to store files in.
; "" = Use the cache folder in the repository (default) ; "" = Use the cache folder in the repository (default)
path = "" path = ""
@ -142,6 +149,7 @@ path = ""
enable_purge = true enable_purge = true
[SQLiteCache] [SQLiteCache]
; Filepath of the sqlite db file ; Filepath of the sqlite db file
file = "cache.sqlite" file = "cache.sqlite"
; Whether to actually delete data when purging ; Whether to actually delete data when purging
@ -150,6 +158,7 @@ enable_purge = true
timeout = 5000 timeout = 5000
[MemcachedCache] [MemcachedCache]
host = "localhost" host = "localhost"
port = 11211 port = 11211

View file

@ -7,10 +7,6 @@ if (is_file(__DIR__ . '/../vendor/autoload.php')) {
const PATH_LIB_CACHES = __DIR__ . '/../caches/'; const PATH_LIB_CACHES = __DIR__ . '/../caches/';
const PATH_CACHE = __DIR__ . '/../cache/'; const PATH_CACHE = __DIR__ . '/../cache/';
// Allow larger files for simple_html_dom
// todo: extract to config (if possible)
const MAX_FILE_SIZE = 10000000;
// Files // Files
$files = [ $files = [
__DIR__ . '/../lib/html.php', __DIR__ . '/../lib/html.php',

View file

@ -114,8 +114,9 @@ function str_get_html(
if (empty($str)) { if (empty($str)) {
throw new \Exception('Refusing to parse empty string input'); throw new \Exception('Refusing to parse empty string input');
} }
if (strlen($str) > MAX_FILE_SIZE) {
throw new \Exception('Refusing to parse too big input'); if (strlen($str) > Configuration::getConfig('system', 'max_file_size')) {
throw new \Exception('simple_html_dom: Refusing to parse too big input: ' . strlen($str));
} }
return $dom->load($str, $lowercase, $stripRN); return $dom->load($str, $lowercase, $stripRN);