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

Enhancement: improve data validation for the give_clean() function #7661

Merged

Conversation

glaubersilva
Copy link
Contributor

@glaubersilva glaubersilva commented Dec 24, 2024

Resolves GIVE-2063

Description

This PR changes the give_clean() function to prevent unserializing data by default, now we are unserializing only when the $allow_serialized_data is true, otherwise, we are returning an empty string when data is serialized.

This PR also improves the regex used in the containsSerializedDataRegex() to cover all data types instead of only arrays and objects.

Affects

As many places are using the give_clean() function, these changes affect the entire codebase, especially the submission of new donations.

Visuals

V2 form error message:
image

V3 form error message:
image

Testing Instructions

  1. Create a V2 and a V3 Donation Form;
  2. Create a test donation using the V2 form and in the donor's first name add the following serialized data: a:1:{s:4:"Test";s:15:"serialize here!";}
  3. Make sure the donation wasn't finished and you got the Error: Please enter your first name. message.
  4. Now create a test donation using the V3 form and in the donor's first name add the following serialized data: a:1:{s:4:"Test";s:15:"serialize here!";}
  5. And make sure the donation wasn't finished and you got the First name is required message.

Pre-review Checklist

  • Acceptance criteria satisfied and marked in related issue
  • Relevant @unreleased tags included in DocBlocks
  • Includes unit tests
  • Reviewed by the designer (if follows a design)
  • Self Review of code and UX completed

@glaubersilva glaubersilva self-assigned this Dec 24, 2024
@glaubersilva glaubersilva changed the title Enhancement: improve data validation Enhancement: improve data validation for give_clean() function Dec 24, 2024
@glaubersilva glaubersilva changed the title Enhancement: improve data validation for give_clean() function Enhancement: improve data validation for the give_clean() function Dec 24, 2024
@glaubersilva glaubersilva marked this pull request as ready for review December 24, 2024 02:11
@jonwaldstein jonwaldstein changed the base branch from master to release/3.19.3 December 24, 2024 15:10
@jonwaldstein jonwaldstein merged commit 29eaaf5 into release/3.19.3 Dec 24, 2024
20 checks passed
@jonwaldstein jonwaldstein deleted the enhancement/improve-data-validation-GIVE-2063 branch December 24, 2024 15:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants