Skip to content

Commit 28ef556

Browse files
Merge pull request #410 from JLG-WOCFR-DEV/codex/audit-du-code-pour-erreurs-et-vulnerabilites
Add permission checks for link editing AJAX handlers
2 parents 212489c + a66f103 commit 28ef556

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

liens-morts-detector-jlg/liens-morts-detector-jlg.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,6 +1162,12 @@ function blc_render_broken_link_row_html(array $row) {
11621162
// Gère la modification d'une URL
11631163
add_action('wp_ajax_blc_edit_link', 'blc_ajax_edit_link_callback');
11641164
function blc_ajax_edit_link_callback() {
1165+
if (!function_exists('blc_current_user_can_fix_links') || !blc_current_user_can_fix_links()) {
1166+
wp_send_json_error([
1167+
'message' => __('Permissions insuffisantes.', 'liens-morts-detector-jlg'),
1168+
], BLC_HTTP_FORBIDDEN);
1169+
}
1170+
11651171
check_ajax_referer('blc_edit_link_nonce');
11661172

11671173
$params = blc_require_post_params(['post_id', 'row_id', 'old_url', 'new_url']);
@@ -1208,6 +1214,12 @@ function blc_ajax_edit_link_callback() {
12081214

12091215
add_action('wp_ajax_blc_apply_detected_redirect', 'blc_ajax_apply_detected_redirect_callback');
12101216
function blc_ajax_apply_detected_redirect_callback() {
1217+
if (!function_exists('blc_current_user_can_fix_links') || !blc_current_user_can_fix_links()) {
1218+
wp_send_json_error([
1219+
'message' => __('Permissions insuffisantes.', 'liens-morts-detector-jlg'),
1220+
], BLC_HTTP_FORBIDDEN);
1221+
}
1222+
12111223
check_ajax_referer('blc_apply_detected_redirect_nonce');
12121224

12131225
$params = blc_require_post_params(['post_id', 'row_id']);

0 commit comments

Comments
 (0)