diff options
| author | kj_sh604 | 2026-03-08 20:06:32 -0400 |
|---|---|---|
| committer | kj_sh604 | 2026-03-08 20:06:45 -0400 |
| commit | d29192b67a4e1f88462d46d8608df98bc978da45 (patch) | |
| tree | 8e6aebea759d5fdfe8e84a6054321a3b0fc34276 /src | |
| parent | fd01077b3f163cbe05be2cfeacdc45d3d060b8a5 (diff) | |
refactor: more friendly font lookup for most server set-ups
Diffstat (limited to 'src')
| -rw-r--r-- | src/font.php | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/font.php b/src/font.php index de39569..d12ceb8 100644 --- a/src/font.php +++ b/src/font.php | |||
| @@ -15,10 +15,16 @@ if ($file === false || !file_exists($file)) { | |||
| 15 | 15 | ||
| 16 | $real = realpath($file); | 16 | $real = realpath($file); |
| 17 | $allowed = ['/usr/share/fonts', '/usr/local/share/fonts']; | 17 | $allowed = ['/usr/share/fonts', '/usr/local/share/fonts']; |
| 18 | $ok = false; | 18 | |
| 19 | foreach (glob('/home/*', GLOB_ONLYDIR) as $home) { | ||
| 20 | $allowed[] = $home . '/.local/share/fonts'; | ||
| 21 | $allowed[] = $home . '/.fonts'; | ||
| 22 | } | ||
| 23 | |||
| 24 | $ok = false; | ||
| 19 | 25 | ||
| 20 | foreach ($allowed as $dir) { | 26 | foreach ($allowed as $dir) { |
| 21 | if (str_starts_with($real, $dir)) { | 27 | if (str_starts_with($real, realpath($dir) ?: $dir)) { |
| 22 | $ok = true; | 28 | $ok = true; |
| 23 | break; | 29 | break; |
| 24 | } | 30 | } |
