Skip to content

Commit 017ab9c

Browse files
webmycwebmyc
authored andcommitted
fix(admin): address Copilot review feedback
- Escape the row class attribute: replace the inline ternary that conditionally injected ` class="disabled"` with a computed `$row_class` string echoed through esc_attr(). Resolves the WordPress.Security.EscapeOutput risk Copilot flagged at line 204. - wp_die() in render_page() now passes response code 403 + back_link so automated clients and access logs reflect the authorization failure correctly instead of falling back to a generic error. Both changes are local to includes/Admin/SettingsPage.php. No behavior change beyond the response code; the same denial still blocks the render path when current_user_can( manage_options ) is false. Refs Copilot review on PR #184. Co-authored-by: webmyc <urbankidro@git.wordpress.org>
1 parent 40cff59 commit 017ab9c

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

includes/Admin/SettingsPage.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,14 @@ public function discover_abilities(): array {
157157
*/
158158
public function render_page(): void {
159159
if ( ! current_user_can( self::CAPABILITY ) ) {
160-
wp_die( esc_html__( 'You do not have permission to access this page.', 'mcp-adapter' ) );
160+
wp_die(
161+
esc_html__( 'You do not have permission to access this page.', 'mcp-adapter' ),
162+
esc_html__( 'Permission denied', 'mcp-adapter' ),
163+
array(
164+
'response' => 403,
165+
'back_link' => true,
166+
)
167+
);
161168
}
162169

163170
$abilities = $this->discover_abilities();
@@ -201,7 +208,8 @@ public function render_page(): void {
201208
</thead>
202209
<tbody>
203210
<?php foreach ( $abilities as $name => $info ) : ?>
204-
<tr<?php echo $info['managed'] ? ' class="disabled"' : ''; ?>>
211+
<?php $row_class = $info['managed'] ? 'disabled' : ''; ?>
212+
<tr class="<?php echo esc_attr( $row_class ); ?>">
205213
<td>
206214
<?php if ( $info['managed'] ) : ?>
207215
<input type="checkbox" disabled aria-label="<?php echo esc_attr( sprintf( /* translators: %s: ability name. */ __( 'Managed by adapter: %s', 'mcp-adapter' ), $name ) ); ?>" />

0 commit comments

Comments
 (0)