Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: extract simple_html_dom max_file_size to config #4395

Merged
merged 1 commit into from
Jan 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions bridges/YoutubeBridge.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
<?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
{
const NAME = 'YouTube Bridge';
Expand Down
9 changes: 9 additions & 0 deletions config.default.ini.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@
; Whether to enable maintenance mode. If enabled, feed requests receive 503 Service Unavailable
enable_maintenance_mode = false

; Max file size for simple_html_dom in bytes (10000000 => 10 MB)
max_file_size = 10000000

[http]

; Operation timeout in seconds
timeout = 15

Expand All @@ -70,6 +74,7 @@
custom_timeout = false

[admin]

; Advertise an email address where people can reach the administrator.
; This address is displayed on the main page, visible to everyone!
; "" = Disabled (default)
Expand All @@ -86,6 +91,7 @@
donations = true

[proxy]

; The HTTP proxy to tunnel requests through
; https://curl.se/libcurl/c/CURLOPT_PROXY.html
; "" = Proxy disabled (default)
Expand Down Expand Up @@ -135,13 +141,15 @@
; --- Cache specific configuration ---------------------------------------------

[FileCache]

; The root folder to store files in.
; "" = Use the cache folder in the repository (default)
path = ""
; Whether to actually delete files when purging. Can be useful to turn off to increase performance.
enable_purge = true

[SQLiteCache]

; Filepath of the sqlite db file
file = "cache.sqlite"
; Whether to actually delete data when purging
Expand All @@ -150,6 +158,7 @@
timeout = 5000

[MemcachedCache]

host = "localhost"
port = 11211

Expand Down
4 changes: 0 additions & 4 deletions lib/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
const PATH_LIB_CACHES = __DIR__ . '/../caches/';
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 = [
__DIR__ . '/../lib/html.php',
Expand Down
5 changes: 3 additions & 2 deletions lib/simplehtmldom/simple_html_dom.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,9 @@ function str_get_html(
if (empty($str)) {
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);
Expand Down
Loading