-
Notifications
You must be signed in to change notification settings - Fork 173
fix WordPress.Security.EscapeOutput.OutputNotEscaped errors #776
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
base: master
Are you sure you want to change the base?
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
kasparsd
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It appears that WP core isn't passing these wp_die() strings through esc_html__() and use __() instead.
Should we keep it consistent with core?
We use this a few times throughout the plugin. Shall we adjust all of this? Then we'll probably have to add this as well ahead so we dont get the issues like #775 anymore. |
| $provider = self::get_provider_for_user( $user, $provider ); | ||
| if ( ! $provider ) { | ||
| wp_die( __( 'Cheatin’ uh?', 'two-factor' ) ); | ||
| wp_die( __( 'Two-factor provider not available for this user.', 'two-factor' ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| wp_die( __( 'Two-factor provider not available for this user.', 'two-factor' ) ); | |
| wp_die( esc_html__( 'Two-factor provider not available for this user.', 'two-factor' ) ); |
I think we still need to escape these translations: PHPCS still complains.
| $login_nonce = self::create_login_nonce( $user->ID ); | ||
| if ( ! $login_nonce ) { | ||
| wp_die( esc_html__( 'Failed to create a login nonce.', 'two-factor' ) ); | ||
| wp_die( __( 'Failed to create a login nonce.', 'two-factor' ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| wp_die( __( 'Failed to create a login nonce.', 'two-factor' ) ); | |
| wp_die( esc_html__( 'Failed to create a login nonce.', 'two-factor' ) ); |
| $provider = self::get_provider_for_user( $user, $provider ); | ||
| if ( ! $provider ) { | ||
| wp_die( __( 'Cheatin’ uh?', 'two-factor' ) ); | ||
| wp_die( __( 'Two-factor provider not available for this user.', 'two-factor' ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| wp_die( __( 'Two-factor provider not available for this user.', 'two-factor' ) ); | |
| wp_die( esc_html__( 'Two-factor provider not available for this user.', 'two-factor' ) ); |
| $login_nonce = self::create_login_nonce( $user->ID ); | ||
| if ( ! $login_nonce ) { | ||
| wp_die( esc_html__( 'Failed to create a login nonce.', 'two-factor' ) ); | ||
| wp_die( __( 'Failed to create a login nonce.', 'two-factor' ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| wp_die( __( 'Failed to create a login nonce.', 'two-factor' ) ); | |
| wp_die( esc_html__( 'Failed to create a login nonce.', 'two-factor' ) ); |
| $provider = self::get_provider_for_user( $user, $provider ); | ||
| if ( ! $provider ) { | ||
| wp_die( __( 'Cheatin’ uh?', 'two-factor' ) ); | ||
| wp_die( __( 'Two-factor provider not available for this user.', 'two-factor' ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| wp_die( __( 'Two-factor provider not available for this user.', 'two-factor' ) ); | |
| wp_die( esc_html__( 'Two-factor provider not available for this user.', 'two-factor' ) ); |
| return new WP_Error( | ||
| 'two_factor_provider_missing', | ||
| __( 'Cheatin’ uh?', 'two-factor' ) | ||
| __( 'Two-factor provider not available for this user.', 'two-factor' ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| __( 'Two-factor provider not available for this user.', 'two-factor' ) | |
| esc_html__( 'Two-factor provider not available for this user.', 'two-factor' ) |
Fixes #775
What?
Fixes WordPress Coding Standards (PHPCS) violations related to unescaped output in class-two-factor-core.php by properly escaping all localized and dynamic output.
Why?
The Two-Factor plugin was triggering WordPress.Security.EscapeOutput.OutputNotEscaped errors when running PHPCS. Several localized strings and formatted values (_n(), number_format_i18n(), human_time_diff(), and __()) were output directly without context-appropriate escaping. This violates WordPress security and coding standards and may block releases or CI checks.
How?
implement the correct escape functions
Testing Instructions
Changelog Entry