guzzle / psr7

PSR-7 HTTP message library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

basename usage restricts usage allowed by the rfc7578

olegabr opened this issue · comments

basename($filename)

The pinata API for directory upload requires to specify filename in a form like 'directory/file.ext': https://pinata.cloud/documentation#PinFileToIPFS

The basename call here prevents such usage and is more restricting than the rfc7578. the standards says:

It is important when interpreting the filename of the Content-Disposition header field to not inadvertently overwrite files in the recipient's file space.

But the basename call here prevents the sender to send any path here. That is more restrictive than a standard and prohibits viable use cases like the pinata directory upload. Remove this basename call please.

Thank you for this issue.

Could you provide a PR with a valid test case that shows why this change is needed?

Just checked what php-http/multipart-stream-builder does, and they also use basename.

The spec also says this:

The receiving MUA SHOULD NOT respect any directory path information that may seem to be present in the filename parameter. The filename should be treated as a terminal component only. Portable specification of directory paths might possibly be done in the future via a separate Content-Disposition parameter, but no provision is made for it in this draft.

Which means that pinata.cloud is not following the spec if it treats foo/bar.txt differently from bar.txt. The spec specifically says that filename cannot be used to infer directory information.

@GrahamCampbell Thank you for your response! I disagree with your logic, but I have a workaround, so, I'm OK with this :-)