commit 2466ff60a11dd1a3eac047b987bd238ae8bd4c88 parent d88035f8dd32420713d28bf26d9496c59c8bb6c1 Author: JayVii <jayvii[AT]posteo[DOT]de> Date: Fri, 25 Oct 2024 17:20:13 +0200 fix: ensure file is only subsetted if content exists Diffstat:
M | lib/helpers.php | | | 7 | ++++++- |
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/lib/helpers.php b/lib/helpers.php @@ -17,7 +17,12 @@ function sort_by_time(array $a, array $b) { function link_in_first_line(string $filepath) { /* read first line of file */ - $file_first_line = file($filepath, FILE_IGNORE_NEW_LINES)[0]; + $file_content = file($filepath, FILE_IGNORE_NEW_LINES); + if (count($file_content) > 0) { + $file_first_line = $file_content[0]; + } else { + $file_first_line = ""; + } /* extract links from first line */ $file_link = preg_replace(