Hi @UBBDev Team,

Iโ€™m running UBB.threads 8.0.0 on PHP 8.2 (Debian / nginx) and noticed the same problem with file downloads that I had already been fixed in an earlier 7.7.5 release.

๐Ÿž Problem
File downloads containing spaces or non-ASCII characters (for example
รœberblick 2025.pdf or My File Name.docx) fail or produce malformed headers.

โš™๏ธ Root Cause
The current code uses a single variable $file for both filesystem and URL purposes,
and directly applies rawurlencode() to it.
When the physical file on disk contains spaces or UTF-8 characters,
the encoded name no longer matches the actual file, resulting in 0-bytes downloads (!).

โœ… Solution (working patch)
I re-applied and updated my original fix for PHP 8.
Key changes:
- Separate filesystem vs. URL filenames
โ†’ $file_fs (actual file on disk)
โ†’ $file_url = rawurlencode($file_fs)
- Path-traversal protection using basename()
- Encoding fallbacks for legacy uploads (UTF-8 โ†” ISO-8859-1 transliteration)
- RFC 6266-compliant headers (filename*= for correct UTF-8 display)
- Improved caching logic (Last-Modified / 304 Not Modified) even without apache_request_headers()
- Accurate MIME types for inline images (image/jpeg, etc.)
- Safe filesystem checks (is_file(), filesize(), filemtime()) to avoid PHP 8 fatals
- The result restores correct downloads and inline display for all tested cases.

๐Ÿ“Ž Suggestion
Please consider re-integrating this logic into a future maintenance release.
It restores correct handling of UTF-8 filenames and spaces in attachments and ensures full PHP 8 compatibility.
I have attached the updated download.inc.php (with detailed English comments) if helpful.
Thanks for keeping UBB.threads modern and PHP 8-ready!

Kind regards
Maik
Attachments
download.inc.txt (7.78 KB, 30 downloads)
SHA1: 4197c77a6125b3bdce7185babc534ee41ad30e80

Last edited by Maik_F; 10/24/2025 4:06 PM.