[php-src] PR #25808: ext/ftp: Add optional MLSD fact name normalization

From: Date: Thu, 26 Nov 2026 21:41:21 +0000
Subject: [php-src] PR #25808: ext/ftp: Add optional MLSD fact name normalization
Groups: php.git-pulls 
Request: Send a blank email to git-pulls+get-41082@lists.php.net to get a copy of this message
Pull Request: https://github.com/php/php-src/pull/25808 Author: WoodenGolem > **LLM disclosure:** This PR description was drafted with AI assistance. > > ## Summary > > RFC 3659 treats MLSD fact names as case-insensitive, but PHP array keys are > case-sensitive. ftp_mlsd() currently returns fact names in the > casing > supplied by the FTP server, which can break callers when that casing changes > (see #18064). > > This PR adds an optional bool $normalize_fact_names = false > parameter. > Calls without the parameter, and calls passing false, retain > the existing > behavior. Passing true lowercases ASCII letters in fact names > before using > them as array keys. Non-ASCII bytes, filenames, and fact values are unchanged. > > For example, given the server response: > > ```text > Type=FiLe;SIZE=51574;UNIX.mode=0644; example.jpg > ``` > > ftp_mlsd($ftp, '.', true) includes an entry > equivalent to: > > ```php > [ > 'name' => 'example.jpg', > 'type' => 'FiLe', > 'size' => '51574', > 'unix.mode' => '0644', > ] > ``` > > ## Collisions and compatibility > > In the opt-in mode, server-supplied > Name/name facts are ignored so they > cannot overwrite PHP's separate name key for the pathname. > If multiple > fact names normalize to the same key (such as Type and > type), the last > fact wins, matching the existing handling of repeated identical fact names. > These rules do not change the default mode. > > This intentionally does not normalize type *values*: RFC 3659 > defines > those values as case-insensitive, but changing values is outside the scope of > this option. > > ## Tests > > The local FTP test server covers default/false equivalence, > mixed-case and > lowercase keys, unchanged filenames and values, > Name/name, collisions, > non-ASCII bytes, empty and missing directories, and malformed responses. > > - Debug build with OpenSSL and FTP-SSL enabled: **67/67 FTP tests passed**, > none skipped (Docker --network none). > - ZTS build: **4/4 MLSD tests passed**. > > Docker network isolation prevents the host's VPN DNS search domain from > resolving a deliberately invalid hostname used by an existing FTP test. > > ## Documentation > > A corresponding php/doc-en update is prepared locally for a > separate PR > after the API shape is confirmed. Applications, including Nextcloud, must > explicitly opt in to use the new parameter; this change alone does not alter > their behavior. > > Related: #18064; [RFC 3659, sections > 7.4–7.5](https://www.rfc-editor.org/rfc/rfc3659#section-7.5).

« previous php.git-pulls (#41082) next »