Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
1 of 3 tasks
Aku-benj opened this issue Aug 8, 2024 · 1 comment
Open
1 of 3 tasks
Labels
status: needs info 🔎 Needs more info before action can be taken

Comments

@Aku-benj
Copy link

Aku-benj commented Aug 8, 2024

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.

  • Yes

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

  • Yes
  • My issue is with a specific 3rd-party plugin.
@justlevine
Copy link
Member

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:

  • please confirm you have disabled all plugins (including GF extensions and custom code) besides WPGraphQL, Gravity Forms, and WPGraphQL for Gravity Forms
  • Share any additional environment details (OS version, etc).

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).

@justlevine justlevine added the status: needs info 🔎 Needs more info before action can be taken label Aug 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs info 🔎 Needs more info before action can be taken
Projects
None yet
Development

No branches or pull requests

2 participants