Skip to content

Commit

Permalink
Prevent sprintf errors by escaping % in form title
Browse files Browse the repository at this point in the history
  • Loading branch information
krokodok committed May 15, 2024
1 parent 0336294 commit 75237f5
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions connectors/class-connector-gravityforms.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ public function register() {
* @param bool $is_new Is this a new form?.
*/
public function callback_gform_after_save_form( $form, $is_new ) {
$title = $form['title'];
$title = str_replace( '%', '%%', $form['title'] );
$id = $form['id'];

$this->log(
Expand Down Expand Up @@ -260,7 +260,7 @@ public function callback_gform_pre_confirmation_save( $confirmation, $form, $is_
__( '"%1$s" confirmation %2$s for "%3$s"', 'stream' ),
$confirmation['name'],
$is_new ? esc_html__( 'created', 'stream' ) : esc_html__( 'updated', 'stream' ),
$form['title']
str_replace( '%', '%%', $form['title'] )
),
array(
'is_new' => $is_new,
Expand Down Expand Up @@ -293,7 +293,7 @@ public function callback_gform_pre_notification_save( $notification, $form, $is_
__( '"%1$s" notification %2$s for "%3$s"', 'stream' ),
$notification['name'],
$is_new ? esc_html__( 'created', 'stream' ) : esc_html__( 'updated', 'stream' ),
$form['title']
str_replace( '%', '%%', $form['title'] )
),
array(
'is_update' => $is_new,
Expand All @@ -319,7 +319,7 @@ public function callback_gform_pre_notification_deleted( $notification, $form )
/* translators: %1$s: a notification name, %2$s: a form title (e.g. "Email", "Contact Form") */
__( '"%1$s" notification deleted from "%2$s"', 'stream' ),
$notification['name'],
$form['title']
str_replace( '%', '%%', $form['title'] )
),
array(
'form_id' => $form['id'],
Expand All @@ -343,7 +343,7 @@ public function callback_gform_pre_confirmation_deleted( $confirmation, $form )
/* translators: %1$s: a confirmation name, %2$s: a form title (e.g. "Email", "Contact Form") */
__( '"%1$s" confirmation deleted from "%2$s"', 'stream' ),
$confirmation['name'],
$form['title']
str_replace( '%', '%%', $form['title'] )
),
array(
'form_id' => $form['id'],
Expand All @@ -369,7 +369,7 @@ public function callback_gform_confirmation_status( $confirmation, $form, $is_ac
__( '"%1$s" confirmation %2$s from "%3$s"', 'stream' ),
$confirmation['name'],
$is_active ? esc_html__( 'activated', 'stream' ) : esc_html__( 'deactivated', 'stream' ),
$form['title']
str_replace( '%', '%%', $form['title'] )
),
array(
'form_id' => $form['id'],
Expand All @@ -396,7 +396,7 @@ public function callback_gform_notification_status( $notification, $form, $is_ac
__( '"%1$s" notification %2$s from "%3$s"', 'stream' ),
$notification['name'],
$is_active ? esc_html__( 'activated', 'stream' ) : esc_html__( 'deactivated', 'stream' ),
$form['title']
str_replace( '%', '%%', $form['title'] )
),
array(
'form_id' => $form['id'],
Expand Down Expand Up @@ -756,7 +756,7 @@ public function callback_gform_update_status( $lead_id, $status, $prev = '' ) {
__( 'Lead #%1$d %2$s on "%3$s" form', 'stream' ),
$lead_id,
$actions[ $status ],
$form['title']
str_replace( '%', '%%', $form['title'] )
),
array(
'lead_id' => $lead_id,
Expand Down Expand Up @@ -791,7 +791,7 @@ public function callback_gform_update_is_read( $lead_id, $status ) {
$lead_id,
$status,
$form['id'],
$form['title']
str_replace( '%', '%%', $form['title'] )
),
array(
'lead_id' => $lead_id,
Expand Down Expand Up @@ -826,7 +826,7 @@ public function callback_gform_update_is_starred( $lead_id, $status ) {
$lead_id,
$status,
$form['id'],
$form['title']
str_replace( '%', '%%', $form['title'] )
),
array(
'lead_id' => $lead_id,
Expand Down Expand Up @@ -945,7 +945,7 @@ public function log_form_action( $form_id, $action ) {
/* translators: %1$d: an ID, %2$s: a form title, %3$s: a status (e.g. "42", "Contact Form", "Activated") */
__( 'Form #%1$d ("%2$s") %3$s', 'stream' ),
$form_id,
$form['title'],
str_replace( '%', '%%', $form['title'] ),
strtolower( $actions[ $action ] )
),
array(
Expand Down

0 comments on commit 75237f5

Please sign in to comment.