AxeWP / wp-graphql-gravity-forms

GraphQL API for interacting with Gravity Forms.
GNU General Public License v3.0
165 stars 29 forks source link

If a File is uploaded with a name containing spaces it disapears. #446

Open Aku-benj opened 3 months ago

Aku-benj commented 3 months ago

Description

The upload of a file containg spaces in his name is not added to the Gform entry at the end of the submit process. I can see the file in the upload/gravity_forms1-xxx/tmp but then the gravity-form code fails to move it to the entry.

Steps to reproduce

1 - Create a form with an upload file field with option Enable Multi-File Upload active 2 - Create a local file with one or multiple spaces in the name 3 - Use the submitGfForm mutation to send the file 4 - The file is not associated to the entry at the end.

Additional context

I think the issue comes from the initialize_files function in the EntryObjectMutation class. If we compare the creation of the $target_file to the one gravityForm uses it is missing the use of sanitize_file_name :

wp-graphql-gravity-forms: wp_basename( $temp_filename )

vs

set_uploaded_files function in GFFormsModel class.

gravity-forms: sanitize_file_name( wp_basename( $upload['temp_filename'] ) )

This leads to the call of file_exists returning a missing file.

Plugin Version

0.13.0.1

Gravity Forms Version

2.8.15

WordPress Version

6.4.3

WPGraphQL Version

1.28.0

Additional enviornmental details

No response

Please confirm that you have searched existing issues in the repo.

Please confirm that you have disabled ALL plugins except for Gravity Forms, WPGraphQL, and WPGraphQL for Gravity Forms

justlevine commented 3 months ago

Hey @Aku-benj thanks for reporting this!

I'm having trouble replicating locally. Do you perhaps have a minimal frontend replication I can try?

Also can you:

Also, just curious but if you change the line in EntryObjectMutation::initialize_files() locally as you propose, does the issue go away?

( GFFormsModel::set_uploaded_files() is actually used within our lifecycle, and EntryObjectMutation::initialize_files() just primes the variables that method looks for, so my gut tells me double-sanitizing there won't help, but I need to be able to replicate to know for sure).