Prerequisites
Steps to reproduce
I am using the invoke-restmethod to do a Multipart/Form-Data Submission using the -Form parameter.
The form date also includes a file.
$DocumentUploadForm = @{
file = Get-Item $DocumentFile
title = "$DocumentTitle"
When the filename contains just ascii chars the filename is encoded as expected in the request body.
However when the filename contains non-ascii chars the filename is encoded as per RFC-1342 which is unexpected.
I have compared the behavior to the CURL application and there the filename is encoded differently using unicode codepoints.
Expected behavior
Request Body for file with non-ascci chars in the filename:
...
--------------------------748339ec18b72df1
Content-Disposition: form-data; name="file"; filename="t\xcc\x88stfile.pdf"
Content-Type: application/pdf
%PDF-1.7
...
Request Body for file with only ascii chars in the filename:
...
--------------------------748339ec18b72df1
Content-Disposition: form-data; name="file"; filename="testfile.pdf"
Content-Type: application/pdf
%PDF-1.7
...
Actual behavior
Request Body for file with non-ascci chars in the filename:
...
--------------------------748339ec18b72df1
Content-Disposition: form-data; name="file"; filename="=?utf-8?B?S3XMiG5kaWd1bmdfTXVzdGVybWFubl9NYXguVFRBXzIwMjNfMDFfMzAucGRm?="
Content-Type: application/pdf
%PDF-1.7
...
Error details
There is no error in the powershell, but the server does not accept the POST request containing this filename encoding.
The server does accept a the POST request created by CURL.
The only difference is the encoding auf the filename.
Either with unicode codepoints or with RFC-1342
Environment data
Name Value
---- -----
PSVersion 7.3.3
PSEdition Core
GitCommitId 7.3.3
OS Darwin 22.4.0 Darwin Kernel Version 22.4.0: Mon Mar 6 20:59:58 PST 2023; root:xnu-8796.101.5~3/RELEASE_ARM64_T6020
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Visuals
No response
Prerequisites
Steps to reproduce
I am using the invoke-restmethod to do a Multipart/Form-Data Submission using the -Form parameter.
The form date also includes a file.
$DocumentUploadForm = @{file = Get-Item $DocumentFiletitle = "$DocumentTitle"When the filename contains just ascii chars the filename is encoded as expected in the request body.
However when the filename contains non-ascii chars the filename is encoded as per RFC-1342 which is unexpected.
I have compared the behavior to the CURL application and there the filename is encoded differently using unicode codepoints.
Expected behavior
Actual behavior
Error details
Environment data
Visuals
No response