Req #70794 [NEW]: Implement RFC 2231 for handling filenames in uploads

From: Date: Mon, 26 Oct 2015 15:20:37 +0000
Subject: Req #70794 [NEW]: Implement RFC 2231 for handling filenames in uploads
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-196819@lists.php.net to get a copy of this message
From:             viskoo at gmail dot com
Operating system: 
PHP version:      5.6.14
Package:          HTTP related
Bug Type:         Feature/Change Request
Bug description:Implement RFC 2231 for handling filenames in uploads

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)

-- 
Edit bug report at https://bugs.php.net/bug.php?id=70794&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=70794&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=70794&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=70794&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=70794&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=70794&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=70794&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=70794&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=70794&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=70794&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=70794&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=70794&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=70794&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=70794&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=70794&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=70794&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=70794&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=70794&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=70794&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=70794&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=70794&r=mysqlcfg



Thread (1 message)

  • viskoo at gmail dot com
« previous php.bugs (#196819) next »