You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Show NL instead of BR when displaying spam entry - #3572
We reviewed changes in 37b7b7a...6772e97 on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.
AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.
$this->assertSame( $expected, FrmSpamEntriesHelper::escape_value( $value ), 'Breaks should become newlines without allowing other markup or changing non-string values.' );
The fix is correct and does what the issue (formidable-pro#6841) asks for. Spam values are escaped in FrmSpamEntriesHelper::escape_value(), and FrmFieldValue runs it over the already-built display value, which is where the address field's <br/> separators arrive. They were being escaped into visible <br/>. The change turns <br>, <br/> and <br /> into a newline before esc_html(), so everything else a spammer submits stays escaped.
Live repro (Playground preview env, Lite + Pro; address field and a textarea, entry marked as spam, rendered through FrmEntriesController::show_entry_shortcode() and [frm-show-entry]):
On master: the Address cell is 123 Main St <br/>Baltimore, MD 12345 <br/>United States, which is the bug from the issue.
On this PR: the same cell is 123 Main St <br />Baltimore, MD 12345 <br />United States, real line breaks. A textarea value with <b>bold</b> <img src=x onerror=alert(1)> still renders as <b>bold</b> <img src=x onerror=alert(1)> on both, so no markup gets through. The entries list cell for the address reads 123 Main St Baltimore, MD 12345 United States.
Tests: both new tests in test_FrmSpamOutput pass on the PR (5/5, 39 assertions, run in a wordpress-develop checkout with Lite's phpunit.xml and Pro present). With only the one-line change reverted, the two new tests fail. The wider Spam/FrmFieldValue/entries filter shows the same 4 errors with and without the change (the first is test_FrmSpamCompatibility::test_old_addon_blocks_spam_storage), so they come from this local setup, not the PR. I could not read their messages: PHPUnit crashes while printing them.
Not exercised: the admin spam tab in a browser (I rendered the same code paths over HTTP instead), Views and email placeholders that call escape_value() through FrmProContent, where a bare newline will not show as a break unless the output is run through nl2br, and the review skills (a one-line change plus tests, read in full instead). CI is skipping every job except typos, and Psalm and the DeepSource and Scrutinizer checks were still pending when I started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes https://github.com/Strategy11/formidable-pro/issues/6841
A spam entry is intentionally fully escaped - no HTML should work for a spam entry.
But this update changes the escapes
<br>tags to\nso line breaks look better.