GravityPDF / gravity-pdf

Gravity PDF is a GPLv2-licensed WordPress plugin that allows you to automatically generate, email and download PDF documents using Gravity Forms.
https://gravitypdf.com
88 stars 21 forks source link

Prevent Fatal error when processing Kses::output with null value. #1430

Closed jestonihpi closed 1 year ago

jestonihpi commented 1 year ago

This PR is a safety precaution when running Kses::output on null values. Added an is_string check before the said output should fix this problem posted in our wordpress.org support.

Description

1427

Testing instructions

Screenshots

Checklist:

Additional Comments

codecov[bot] commented 1 year ago

Codecov Report

Merging #1430 (07947cd) into development (f6e0cb4) will decrease coverage by 0.29%. The diff coverage is 100.00%.

@@                Coverage Diff                @@
##             development    #1430      +/-   ##
=================================================
- Coverage          75.99%   75.70%   -0.30%     
+ Complexity          2943     2934       -9     
=================================================
  Files                243      243              
  Lines              10129    12820    +2691     
  Branches             370      370              
=================================================
+ Hits                7698     9705    +2007     
- Misses              2423     3107     +684     
  Partials               8        8              
Impacted Files Coverage Δ
src/Statics/Kses.php 99.55% <100.00%> (+1.72%) :arrow_up:
src/templates/config/legacy.php 9.09% <0.00%> (-15.91%) :arrow_down:
src/Helper/Helper_Pdf_Queue.php 72.58% <0.00%> (-11.21%) :arrow_down:
src/Helper/Fields/Field_Textarea.php 70.00% <0.00%> (-7.78%) :arrow_down:
src/Statics/Queue_Callbacks.php 31.14% <0.00%> (-7.63%) :arrow_down:
src/Helper/Helper_Misc.php 68.03% <0.00%> (-6.51%) :arrow_down:
src/Model/Model_Uninstall.php 54.54% <0.00%> (-5.84%) :arrow_down:
src/View/View_Settings.php 28.04% <0.00%> (-5.57%) :arrow_down:
src/Controller/Controller_Save_Core_Fonts.php 12.30% <0.00%> (-5.48%) :arrow_down:
src/Model/Model_Install.php 48.41% <0.00%> (-5.16%) :arrow_down:
... and 97 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

jakejackson1 commented 1 year ago

@jestonihpi Upon thinking about this further, I think the best solution would be to edit the Kses class directly, remove the string type from the property and then check for a string at the beginning of the associated method(s). If it isn't a string, throw a GravityPdfException at this point so our error handlers can capture this.

jestonihpi commented 1 year ago

Hi @jakejackson1, this PR is now ready for review.