Skip to content

Commit

Permalink
Merge pull request #1562 from GravityPDF/hot-patch-6-11.3
Browse files Browse the repository at this point in the history
Fix truncated merge tags in HTML attribute when included in PDF setting Rich Text fields
  • Loading branch information
jakejackson1 authored Aug 18, 2024
2 parents f673065 + 364fc70 commit 83e0b02
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 10 deletions.
5 changes: 4 additions & 1 deletion README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Donate link: https://gravitypdf.com/donate-to-plugin/
Tags: gravity forms, form, contact form, pdf, email
Requires at least: 5.3
Tested up to: 6.6
Stable tag: 6.11.2
Stable tag: 6.11.3
Requires PHP: 7.3
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl.txt
Expand Down Expand Up @@ -107,6 +107,9 @@ Gravity PDF can be run on most modern shared web hosting without any issues. It

== Changelog ==

= 6.11.3 =
* Bug: Fix truncated merge tags in HTML attribute when included in PDF setting Rich Text fields

= 6.11.2 =
* Bug: Resolve race condition by skipping PDF cleanup at the end of form submission process if PDF Background Processing is enabled
* Bug: Fix issue where some Notifications with PDFs attached were not being handled in a background task when PDF Background Processing is enabled
Expand Down
4 changes: 2 additions & 2 deletions pdf.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/*
Plugin Name: Gravity PDF
Version: 6.11.2
Version: 6.11.3
Description: Automatically generate highly customizable PDF documents using Gravity Forms.
Author: Blue Liquid Designs
Author URI: https://blueliquiddesigns.com.au
Expand All @@ -28,7 +28,7 @@
/*
* Set base constants we'll use throughout the plugin
*/
define( 'PDF_EXTENDED_VERSION', '6.11.2' ); /* the current plugin version */
define( 'PDF_EXTENDED_VERSION', '6.11.3' ); /* the current plugin version */
define( 'PDF_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); /* plugin directory path */
define( 'PDF_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); /* plugin directory url */
define( 'PDF_PLUGIN_BASENAME', plugin_basename( __FILE__ ) ); /* the plugin basename */
Expand Down
6 changes: 3 additions & 3 deletions src/Helper/Helper_Abstract_Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -1286,10 +1286,10 @@ public function sanitize_all_fields( $value, $key, $input, $settings ) {
* When outputting rich text, it is important that the merge tags get processed first and then the output
* run through Kses::parse() or Kses::output() to ensure the HTML safe.
*/
$pattern = '{[^{]*?:(\d+(\.\d+)?)(:(.*?))?}';
$value = preg_replace( "/$pattern/mi", 'telnet://$0', $value );
$pattern = '([^{]*?})';
$value = preg_replace( "/=\"\{$pattern\"/mi", '="telnet://$1"', $value );
$value = Kses::parse( $value );
$value = preg_replace( "/telnet:\/\/($pattern)/mi", '$1', $value );
$value = preg_replace( "/=\"telnet:\/\/$pattern\"/mi", '="{$1"', $value );
} else {
/* Don't encode/decode merge tag before sanitizing */
$value = Kses::parse( $value );
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/utilities/page-model/helpers/advanced-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class AdvancedCheck {
this.templateItem = Selector('#the-list').find('tr')
this.pdfListSection = Selector('.gform-settings__navigation').find('a').withText('PDF')
this.toggleSwitch = Selector('#the-list').find('.check-column button')
this.entryItemSection = Selector('#the-list').find('a').withAttribute('aria-label', 'View this entry')
this.entryItemSection = Selector('#the-list').find('td.column-primary')
this.viewPdfLink = Selector('#the-list').find('a').withText('View PDF')
this.editLink = Selector('#the-list').find('span').withText('Edit')
this.conditionalLogicCheckbox = Selector('#gfpdf-fieldset-gfpdf_form_settings_general').find('[id="gfpdf_conditional_logic"]')
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/utilities/page-model/tabs/general-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class General {
this.saveSettings = Selector('#submit-and-promo-container').find('input')

// PDF entries section
this.viewEntryItem = Selector('a').withAttribute('aria-label', 'View this entry')
this.viewEntryItem = Selector('#the-list').find('td.column-primary')
}

async navigateSettingsTab (text) {
Expand Down
16 changes: 14 additions & 2 deletions tests/phpunit/unit-tests/test-options-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -998,8 +998,8 @@ public function provider_sanitize_all_fields() {

[
'rich_editor',
'<a href="{Field:1}">Link</a> and this {Business Name::2} is another <a class="{Field:3}" href="{pdf:12345789:signed,download}">link</a>',
'<a href="{Field:1}">Link</a> and this {Business Name::2} is another <a class="{Field:3}" href="{pdf:12345789:signed,download}">link</a>',
'<a href="{Field:1}">Link</a> and this {Business Name::2} is another <a class="{Field:3}" href="{pdf:12345789ABC:signed,download}">link</a>',
'<a href="{Field:1}">Link</a> and this {Business Name::2} is another <a class="{Field:3}" href="{pdf:12345789ABC:signed,download}">link</a>',
],

[
Expand All @@ -1008,6 +1008,18 @@ public function provider_sanitize_all_fields() {
'<a href="telnet://{Field:1}">Link</a>',
],

[
'rich_editor',
'<a href="{user:user_meta}">Link</a> and this {Business Name::2}',
'<a href="{user:user_meta}">Link</a> and this {Business Name::2}',
],

[
'rich_editor',
'<a href="{embed_url}">Link</a> and this {Business Name::2}',
'<a href="{embed_url}">Link</a> and this {Business Name::2}',
],

[
'textarea',
'<em>Test</em> <script>console.log("test");</script>',
Expand Down

0 comments on commit 83e0b02

Please sign in to comment.