php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #70794 Implement RFC 2231 for handling filenames in uploads
Submitted: 2015-10-26 15:20 UTC Modified: -
Votes:3
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: viskoo at gmail dot com Assigned:
Status: Open Package: HTTP related
PHP Version: 5.6.14 OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: viskoo at gmail dot com
New email:
PHP Version: OS:

 

 [2015-10-26 15:20 UTC] viskoo at gmail dot com
Description:
------------
The aforementioned RFC deals with how to encode filenames when sending files as part of a POST request. If PHP receives a request from a client that implements this RFC, and the filename has special characters, the uploaded files will be lost ($_FILES will be empty), and a warning will be produced:

PHP Warning:  File Upload Mime headers garbled in Unknown on line 0

It doesn't matter if you put Apache, or nginx in front of PHP, or use the built in webserver.

http://tools.ietf.org/html/rfc2231

Test script:
---------------
Create an index.php file:

<?php

header('content-type', 'application/json');
echo json_encode($_FILES);

Launch the webserver with php -S localhost:9000.

Use this python script that uses the requests library to make an RFC 2231 compliant request:

import requests

filename = 'fårikål.txt'
destination = 'http://localhost:9000'
files = { filename: 'hello world' }

res = requests.post(destination, files=files)
print(res.status_code, res.text)

Expected result:
----------------
{
  "får": {
    "name": "får.txt",
    "type": "text/plain",
    "tmp_name": "/tmp/phpuXCXkF",
    "error": 0,
    "size": 12
  }
}

Actual result:
--------------
200 []

(empty result due to the warning, and status code 200)

Patches

Pull Requests

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 17:01:58 2024 UTC