Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hard coded string sanitation removed #361 #362

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions foo-bar.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
* Admin notice for incompatible versions of PHP.
*/
function _foo_bar_php_version_error() {
printf( '<div class="error"><p>%s</p></div>', esc_html( _foo_bar_php_version_text() ) );
printf( '<div class="error"><p>%s</p></div>', _foo_bar_php_version_text() );
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we keep the esc_html() sanitiser during the output here? Currently it is being removed from all paces.

The best practice would be to sanitize late when we know the type of output we're serving. Technically, the return value of _foo_bar_php_version_text() could be used for things like REST API errors, JS callback errors which would each require a different santiser.

}

/**
Expand All @@ -53,5 +53,5 @@ function _foo_bar_php_version_error() {
* @return string
*/
function _foo_bar_php_version_text() {
return esc_html__( 'Foo Bar plugin error: Your version of PHP is too old to run this plugin. You must be running PHP 5.6.20 or higher.', 'foo-bar' );
return __( 'Foo Bar plugin error: Your version of PHP is too old to run this plugin. You must be running PHP 5.6.20 or higher.', 'foo-bar' );
}