Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions classes/controllers/FrmHooksController.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,13 @@ public static function load_hooks() {
add_action( 'wp_scheduled_delete', 'FrmForm::scheduled_delete' );

// Clear embed posts transient when posts are updated.
add_action( 'wp_insert_post', 'FrmFormsListHelper::maybe_clear_embed_posts_transient', 10, 3 );
add_action( 'post_updated', 'FrmFormsListHelper::maybe_clear_embed_posts_transient_on_update', 10, 3 );
add_action( 'trashed_post', 'FrmFormsListHelper::clear_embed_posts_transient_for_post' );
add_action( 'untrashed_post', 'FrmFormsListHelper::clear_embed_posts_transient_for_post' );
add_action( 'deleted_post', 'FrmFormsListHelper::clear_embed_posts_transient_for_post', 10, 2 );
// These call FrmFormEmbedsHelper directly so a front end post save does not have to load
// the FrmFormsListHelper admin list table.
add_action( 'wp_insert_post', 'FrmFormEmbedsHelper::maybe_clear_on_insert', 10, 3 );
add_action( 'post_updated', 'FrmFormEmbedsHelper::maybe_clear_on_update', 10, 3 );
add_action( 'trashed_post', 'FrmFormEmbedsHelper::maybe_clear_for_post' );
add_action( 'untrashed_post', 'FrmFormEmbedsHelper::maybe_clear_for_post' );
add_action( 'deleted_post', 'FrmFormEmbedsHelper::maybe_clear_for_post', 10, 2 );

// Form Shortcodes.
add_shortcode( 'formidable', 'FrmFormsController::get_form_shortcode' );
Expand Down
8 changes: 5 additions & 3 deletions classes/helpers/FrmAppHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -1099,9 +1099,11 @@ public static function kses_submit_button( $html ) {
remove_filter( 'frm_striphtml_allowed_tags', 'FrmAppHelper::add_allowed_submit_button_tags' );

if ( $included_button_action ) {
if ( str_contains( $html, '<input type="submit"' ) ) {
$pattern = '/(<input type="submit")([^>]*)(\/>)/';
$html = preg_replace( $pattern, '$1$2[button_action] $3', $html, 1 );
// Since WordPress 7.2, wp_kses sorts attributes and drops the self-closing slash from void tags.
$input_pattern = '/(<input\b[^>]*\btype="submit"[^>]*?)(\s*\/?>)/';

if ( preg_match( $input_pattern, $html ) ) {
$html = preg_replace( $input_pattern, '$1 [button_action]$2', $html, 1 );
} else {
$pattern = '/(<button)(.*)(class=")(.*)(frm_button_submit)(.*)(")(.*)([^>]+)(>)/';
$html = preg_replace( $pattern, '$1$2$3$4$5$6$7 [button_action]$8$9$10', $html, 1 );
Expand Down
26 changes: 25 additions & 1 deletion classes/models/FrmEntryFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -554,11 +554,35 @@ protected function push_single_field_to_array( $field_value, &$output ) {
$output[ $this->get_key_or_id( $field_value ) ] = $displayed_value;
$has_separate_value = (bool) $field_value->get_field_option( 'separate_value' );

if ( $has_separate_value || $displayed_value !== $field_value->get_saved_value() ) {
if ( $has_separate_value || ! $this->is_same_value_ignoring_line_endings( $displayed_value, $field_value->get_saved_value() ) ) {
$output[ $this->get_key_or_id( $field_value ) . '-value' ] = $field_value->get_saved_value();
}
}

/**
* Compare a displayed value with its saved value, ignoring line ending differences.
* Since WordPress 7.2, wp_kses converts CRLF line endings to LF, so a paragraph value
* submitted from a textarea would otherwise always look different from its display value.
*
* @since x.x
*
* @param mixed $displayed_value The value prepared for display.
* @param mixed $saved_value The value saved in the database.
*
* @return bool
*/
private function is_same_value_ignoring_line_endings( $displayed_value, $saved_value ) {
if ( $displayed_value === $saved_value ) {
return true;
}

if ( ! is_string( $displayed_value ) || ! is_string( $saved_value ) ) {
return false;
}

return str_replace( "\r\n", "\n", $displayed_value ) === str_replace( "\r\n", "\n", $saved_value );
}

/**
* Add a row of values to the plain text content
*
Expand Down
28 changes: 28 additions & 0 deletions classes/models/FrmMigrate.php
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ private function create_tables() {
* @since 6.6
* @since 6.16.3 idx_form_id_is_draft was also added to frm_items.
* @since 6.17 idx_form_id_type was also added to frm_fields.
* @since x.x idx_form_id_created_at was added to frm_items, and idx_parent_form_id and frm_forms_template_status to frm_forms.
*
* @return void
*/
Expand Down Expand Up @@ -326,6 +327,33 @@ private function add_composite_indexes() {
$wpdb->query( "CREATE INDEX idx_form_id_type ON `{$wpdb->prefix}frm_fields` (form_id, type(30))" );
}

/**
* The entry list sorts one form's entries by created_at, without filtering on is_draft.
* KEY form_id alone cannot satisfy that ORDER BY, so the database read every matching row
* and sorted it: on a form with 50,000 entries the first page took about 100ms.
*
* The is_draft column is deliberately left out. Putting it between form_id and created_at
* leaves created_at unusable for the sort whenever is_draft is unconstrained, which is
Comment on lines +330 to +336

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

State the fact, not the benchmark. A measured timing narrates an event and goes stale; the second paragraph is the useful gotcha, so keep that.

Suggested change
/**
* The entry list sorts one form's entries by created_at, without filtering on is_draft.
* KEY form_id alone cannot satisfy that ORDER BY, so the database read every matching row
* and sorted it: on a form with 50,000 entries the first page took about 100ms.
*
* The is_draft column is deliberately left out. Putting it between form_id and created_at
* leaves created_at unusable for the sort whenever is_draft is unconstrained, which is
* The entry list sorts one form's entries by created_at without filtering on is_draft.
* is_draft is deliberately left out of the index: between form_id and created_at it would
* make created_at unusable for the sort. Draft filtering uses idx_form_id_is_draft.

* exactly how the entry list queries. Draft filtering is served by idx_form_id_is_draft.
*/
$table_name = "{$wpdb->prefix}frm_items";
$index_name = 'idx_form_id_created_at';

if ( ! self::index_exists( $table_name, $index_name ) ) {
$wpdb->query( "CREATE INDEX idx_form_id_created_at ON `{$wpdb->prefix}frm_items` (form_id, created_at)" );
}

/**
* Repeaters and embedded forms look their child forms up by parent_form_id, which had
* no index at all, so every lookup was a full scan of frm_forms.
Comment on lines +347 to +348

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Present tense, no history ("which had no index at all" reads as a changelog).

Suggested change
* Repeaters and embedded forms look their child forms up by parent_form_id, which had
* no index at all, so every lookup was a full scan of frm_forms.
* Repeaters and embedded forms look their child forms up by parent_form_id.

*/
$table_name = "{$wpdb->prefix}frm_forms";
$index_name = 'idx_parent_form_id';

if ( ! self::index_exists( $table_name, $index_name ) ) {
$wpdb->query( "CREATE INDEX idx_parent_form_id ON `{$wpdb->prefix}frm_forms` (parent_form_id)" );
}

$table_name = "{$wpdb->prefix}frm_forms";
$index_name = 'frm_forms_template_status';

Expand Down
2 changes: 1 addition & 1 deletion js/formidable_admin.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/src/admin/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -12908,7 +12908,7 @@ window.frmAdminBuildJS = function() {

// The uninstall checkbox only reveals its action, license keys save separately, and payment section inputs act as tabs.
// This is delegated from the wrap element, not the document, because hideShowItem returns false and stops change events from reaching the document.
jQuery( '#form_global_settings' ).on( 'change', 'input:not(#frm-uninstall-box):not(.frm-search-input):not(.frm_addon_license_key):not([name="frm_payment_section"]), select, textarea', fieldUpdated );
jQuery( '#form_global_settings' ).on( 'change', 'input:not(#frm-uninstall-box):not(.frm-search-input):not(.frm_addon_license_key):not([name^="proplug-"]):not([name="frm_payment_section"]), select, textarea', fieldUpdated );

addCustomCSSEditorChangeListener();

Expand Down
8 changes: 7 additions & 1 deletion paypal/controllers/FrmPayPalLiteHooksController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@ public static function load_hooks() {

add_filter( 'frm_payment_gateways', 'FrmPayPalLiteAppController::add_gateway' );

add_action( 'init', 'FrmPayPalLiteConnectHelper::check_for_redirects' );
// Only hook this up on the OAuth return request. Registering it unconditionally made
// WordPress autoload FrmPayPalLiteConnectHelper on every front end page view.
// Paired with FrmPayPalLiteConnectHelper::user_landed_on_the_oauth_return_url, which
// checks the same query argument.
Comment on lines +17 to +20

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Registering it unconditionally made WordPress autoload…" narrates what used to happen. Same wording is in the Square and Stripe controllers. State the present fact:

Suggested change
// Only hook this up on the OAuth return request. Registering it unconditionally made
// WordPress autoload FrmPayPalLiteConnectHelper on every front end page view.
// Paired with FrmPayPalLiteConnectHelper::user_landed_on_the_oauth_return_url, which
// checks the same query argument.
// Only hook this up on the OAuth return request, so the connect helper isn't autoloaded on every page view.
// Same query argument as FrmPayPalLiteConnectHelper::user_landed_on_the_oauth_return_url.

if ( isset( $_GET['frm_paypal_api_return_oauth'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
add_action( 'init', 'FrmPayPalLiteConnectHelper::check_for_redirects' );
}

// Use 20 so this happens after the Stripe add-on.
add_filter( 'frm_pro_show_card_callback', 'FrmPayPalLiteActionsController::maybe_show_card', 20, 2 );
Expand Down
8 changes: 7 additions & 1 deletion square/controllers/FrmSquareLiteHooksController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@ public static function load_hooks() {

add_filter( 'frm_payment_gateways', 'FrmSquareLiteAppController::add_gateway' );

add_action( 'init', 'FrmSquareLiteConnectHelper::check_for_redirects' );
// Only hook this up on the OAuth return request. Registering it unconditionally made
// WordPress autoload FrmSquareLiteConnectHelper on every front end page view.
// Paired with FrmSquareLiteConnectHelper::user_landed_on_the_oauth_return_url, which
// checks the same query argument.
if ( isset( $_GET['frm_square_api_return_oauth'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
add_action( 'init', 'FrmSquareLiteConnectHelper::check_for_redirects' );
}

// Use 20 so this happens after the Stripe add-on.
add_filter( 'frm_pro_show_card_callback', 'FrmSquareLiteActionsController::maybe_show_card', 20, 2 );
Expand Down
25 changes: 24 additions & 1 deletion stripe/controllers/FrmStrpLiteHooksController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ public static function load_hooks() {
// Actions.
add_action( 'frm_entry_form', 'FrmStrpLiteAuth::add_hidden_token_field' );
add_action( 'frm_enqueue_form_scripts', 'FrmStrpLiteActionsController::maybe_load_scripts' );
add_action( 'init', 'FrmStrpLiteConnectHelper::check_for_stripe_connect_webhooks' );

// Only hook this up on requests it can act on. Registering it unconditionally made
// WordPress autoload FrmStrpLiteConnectHelper on every front end page view.
if ( self::request_may_be_for_stripe_connect() ) {
add_action( 'init', 'FrmStrpLiteConnectHelper::check_for_stripe_connect_webhooks' );
}

// Filters.
add_filter( 'frm_saved_errors', 'FrmStrpLiteAppController::maybe_add_payment_error', 10, 2 );
Expand Down Expand Up @@ -52,6 +57,24 @@ function ( $form_col ) {
add_action( 'frm_form_classes', 'FrmStrpLiteLinkController::add_form_classes' );
}

/**
* Could this request be a Stripe Connect return trip or one of the Connect AJAX actions?
*
* Used to keep FrmStrpLiteConnectHelper out of ordinary page views. The helper still runs
* its own narrower checks, this only decides whether it is worth loading at all.
*
* @since x.x
*
* @return bool
*/
private static function request_may_be_for_stripe_connect() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

request_may_be_for_stripe_connect() has one call site and is one line of logic. Under the single-use-extraction rubric, inline it into the if unless a second caller is planned. The phpcs:disable/enable pair moves with it. Not blocking: nothing breaks as written.

// These two query arguments are also checked in FrmStrpLiteConnectHelper, by
// user_landed_on_the_return_url and user_landed_on_the_oauth_return_url.
// phpcs:disable WordPress.Security.NonceVerification.Recommended
return wp_doing_ajax() || isset( $_GET['frm_stripe_connect_return'] ) || isset( $_GET['frm_stripe_connect_return_oauth'] );
// phpcs:enable WordPress.Security.NonceVerification.Recommended
}

/**
* @return void
*/
Expand Down
9 changes: 6 additions & 3 deletions stripe/controllers/FrmTransLiteHooksController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ class FrmTransLiteHooksController {
* @return void
*/
public static function load_hooks() {
add_action( 'frm_add_form_option_section', 'FrmSquareLiteActionsController::actions_js' );

// Exit early, let the Payments submodule handle everything.
if ( class_exists( 'FrmTransHooksController', false ) ) {
return;
Expand All @@ -19,7 +17,6 @@ public static function load_hooks() {
// Actions.
add_action( 'frm_payment_cron', 'FrmTransLiteAppController::run_payment_cron' );
add_filter( 'frm_registered_form_actions', 'FrmTransLiteActionsController::register_actions' );
add_action( 'frm_add_form_option_section', 'FrmTransLiteActionsController::actions_js' );
add_action( 'frm_trigger_payment_action', 'FrmTransLiteActionsController::trigger_action', 10, 3 );

// Filters.
Expand All @@ -38,6 +35,10 @@ public static function load_hooks() {
public static function load_admin_hooks() {
add_action( 'frm_disconnected_gateway', 'FrmTransLiteAppController::maybe_remove_payment_cron', 10, 2 );

// frm_add_form_option_section only fires while rendering the form settings page, so these
// belong here rather than in load_hooks.
add_action( 'frm_add_form_option_section', 'FrmSquareLiteActionsController::actions_js' );

if ( class_exists( 'FrmTransHooksController', false ) ) {
add_action( 'frm_pay_show_square_options', 'FrmTransLiteAppController::add_repeat_cadence_value' );

Expand Down Expand Up @@ -73,6 +74,8 @@ function () {
add_action( 'admin_print_styles', array( self::class, 'hide_collect_payment_action' ) );
}

add_action( 'frm_add_form_option_section', 'FrmTransLiteActionsController::actions_js' );

// Actions.
add_action( 'admin_menu', 'FrmTransLitePaymentsController::menu', 25 );
add_action( 'admin_head', 'FrmTransLiteListsController::add_list_hooks' );
Expand Down
15 changes: 13 additions & 2 deletions tests/phpunit/entries/test_FrmShowEntryShortcode.php
Original file line number Diff line number Diff line change
Expand Up @@ -981,7 +981,18 @@ protected function get_field_html_value( $entry, $field, $atts ) {
* @param array $atts
*/
protected function get_field_plain_text_value( $entry, $field, $atts ) {
return $this->get_field_value( $entry, $field, $atts );
return $this->with_kses_line_endings( $this->get_field_value( $entry, $field, $atts ) );
}

/**
* Since WordPress 7.2, wp_kses converts CRLF line endings to LF. Older versions keep them.
*
* @param mixed $value Expected field value.
*
* @return mixed
*/
protected function with_kses_line_endings( $value ) {
return is_string( $value ) ? str_replace( "\r\n", wp_kses_post( "\r\n" ), $value ) : $value;
}

/**
Expand Down Expand Up @@ -1184,7 +1195,7 @@ protected function expected_default_array( $atts ) {
protected function expected_array( $entry, $atts ) {
$expected = array(
'free-text-field' => 'Test Testerson',
'free-paragraph-field' => "Test\r\nMiddle\r\nTesterson",
'free-paragraph-field' => $this->with_kses_line_endings( "Test\r\nMiddle\r\nTesterson" ),
'free-checkboxes' => array( 'Red', 'Green' ),
'free-radio-button-field' => 'cookies',
'free-dropdown-field' => 'Ace Ventura',
Expand Down
24 changes: 13 additions & 11 deletions tests/phpunit/misc/test_FrmAppHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ public function test_sanitize_request() {
}

public function test_kses() {
$start_value = '<script><script>';
$start_value = '<script></script><script></script>';
$safe_value = 'Hello, <a href="/test">click here</a>';
$start_value .= $safe_value;
$stripped_value = FrmAppHelper::kses( $start_value );
Expand All @@ -264,34 +264,36 @@ public function test_kses() {

public function test_kses_submit_button() {
$default_submit_button_html = '<div class="frm_submit">
[if back_button]<button type="submit" name="frm_prev_page" formnovalidate="formnovalidate" class="frm_prev_page" [back_hook]>[back_label]</button>[/if back_button]
[if back_button]<button class="frm_prev_page" [back_hook] formnovalidate="formnovalidate" name="frm_prev_page" type="submit">[back_label]</button>[/if back_button]
<button class="frm_button_submit" type="submit" [button_action]>[button_label]</button>
[if save_draft]<a href="#" tabindex="0" class="frm_save_draft" [draft_hook]>[draft_label]</a>[/if save_draft]
[if save_draft]<a class="frm_save_draft" [draft_hook] href="#" tabindex="0">[draft_label]</a>[/if save_draft]
</div>';
$this->assertSame(

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Call to an undefined method test_FrmAppHelper::assertSame()


The method you are trying to call is not defined, which can result in a fatal error.

$default_submit_button_html,
FrmAppHelper::kses_submit_button( $default_submit_button_html )
);

$with_custom_class = '<div class="frm_submit">
[if back_button]<button type="submit" name="frm_prev_page" formnovalidate="formnovalidate" class="frm_prev_page" [back_hook]>[back_label]</button>[/if back_button]
[if back_button]<button class="frm_prev_page" [back_hook] formnovalidate="formnovalidate" name="frm_prev_page" type="submit">[back_label]</button>[/if back_button]
<button class="frm_button_submit frm_inline_submit" type="submit" [button_action]>[button_label]</button>
[if save_draft]<a href="#" tabindex="0" class="frm_save_draft" [draft_hook]>[draft_label]</a>[/if save_draft]
[if save_draft]<a class="frm_save_draft" [draft_hook] href="#" tabindex="0">[draft_label]</a>[/if save_draft]
</div>';
$this->assertSame(

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Call to an undefined method test_FrmAppHelper::assertSame()


The method you are trying to call is not defined, which can result in a fatal error.

$with_custom_class,
FrmAppHelper::kses_submit_button( $with_custom_class )
);

$previous_default_html = '<div class="frm_submit">
[if back_button]<input type="button" value="[back_label]" name="frm_prev_page" formnovalidate="formnovalidate" class="frm_prev_page" [back_hook] />[/if back_button]
[if back_button]<input class="frm_prev_page" [back_hook] formnovalidate="formnovalidate" name="frm_prev_page" type="button" value="[back_label]" />[/if back_button]
<input type="submit" value="[button_label]" [button_action] />
<img class="frm_ajax_loading" src="[frmurl]/images/ajax_loader.gif" alt="Sending" style="visibility:hidden" />
<img alt="Sending" class="frm_ajax_loading" src="[frmurl]/images/ajax_loader.gif" style="visibility:hidden" />
[if save_draft]<a class="frm_save_draft" [draft_hook]>[draft_label]</a>[/if save_draft]
</div>';
// Since WordPress 7.2, wp_kses drops the self-closing slash from void tags.
$this->assertSame(

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Call to an undefined method test_FrmAppHelper::assertSame()


The method you are trying to call is not defined, which can result in a fatal error.

$previous_default_html,
FrmAppHelper::kses_submit_button( $previous_default_html )
str_replace( ' />', '>', $previous_default_html ),
str_replace( ' />', '>', FrmAppHelper::kses_submit_button( $previous_default_html ) ),
'The legacy submit button HTML should keep its shortcodes.'
);
}

Expand All @@ -305,10 +307,10 @@ public function test_kses_icon() {
$icon = '<svg class="frmsvg frm_zapier_icon frm_show_upgrade" style="--primary-700:#efefef"><use href="#frm_zapier_icon" /></svg>';
$this->assertSame( $icon, FrmAppHelper::kses_icon( $icon ) );

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Call to an undefined method test_FrmAppHelper::assertSame()


The method you are trying to call is not defined, which can result in a fatal error.


$icon = '<svg class="frmsvg frm_more_horiz_solid_icon frm-show-inline-modal" data-open="frm-layout-classes-box" title="Toggle Options" tabindex="0"><use href="#frm_more_horiz_solid_icon" /></svg>'; // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
$icon = '<svg class="frmsvg frm_more_horiz_solid_icon frm-show-inline-modal" data-open="frm-layout-classes-box" tabindex="0" title="Toggle Options"><use href="#frm_more_horiz_solid_icon" /></svg>'; // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
$this->assertSame( $icon, FrmAppHelper::kses_icon( $icon ) );

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Call to an undefined method test_FrmAppHelper::assertSame()


The method you are trying to call is not defined, which can result in a fatal error.


$icon = '<svg class="frmsvg" aria-label="WordPress" style="width:90px;height:90px"><use href="#frm_wordpress_icon" /></svg>';
$icon = '<svg aria-label="WordPress" class="frmsvg" style="width:90px;height:90px"><use href="#frm_wordpress_icon" /></svg>';
$this->assertSame( $icon, FrmAppHelper::kses_icon( $icon ) );

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Call to an undefined method test_FrmAppHelper::assertSame()


The method you are trying to call is not defined, which can result in a fatal error.

}

Expand Down
4 changes: 3 additions & 1 deletion tests/phpunit/misc/test_FrmSpamOutput.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ public function test_sidebar_referrer_preserves_line_breaks() {
} finally {
ob_end_clean();
}
$this->assertStringContainsString( "https://example.com/<br />\n&lt;img src=x onerror=alert(1)&gt;<br />\r\nLast line", $html );
// Since WordPress 7.2, wp_kses outputs <br> and converts CRLF line endings to LF.
$expected = wp_kses( "https://example.com/<br />\n&lt;img src=x onerror=alert(1)&gt;<br />\r\nLast line", array( 'br' => array() ) );
$this->assertStringContainsString( $expected, $html );

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Call to an undefined method test_FrmSpamOutput::assertStringContainsString()


The method you are trying to call is not defined, which can result in a fatal error.

$this->assertStringNotContainsString( '<img src=x', $html );
}
}
Expand Down
Loading