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

Replace deprecated FILTER_SANITIZE_STRING #2529

Merged
merged 3 commits into from
Mar 28, 2022
Merged
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
12 changes: 6 additions & 6 deletions includes/classes/Feature/Search/Synonyms.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public function admin_notices() {
return;
}

$update = filter_input( INPUT_GET, 'ep_synonym_update', FILTER_SANITIZE_STRING );
$update = filter_input( INPUT_GET, 'ep_synonym_update', FILTER_SANITIZE_SPECIAL_CHARS );

if ( ! in_array( $update, [ 'success', 'error-update-post', 'error-update-index' ], true ) ) {
return;
Expand Down Expand Up @@ -327,7 +327,7 @@ public function validate_synonym( $synonym ) {
return false;
}

return filter_var( trim( $synonym ), FILTER_SANITIZE_STRING );
return sanitize_text_field( $synonym, true );
}

/**
Expand Down Expand Up @@ -386,13 +386,13 @@ public function add_search_synonyms( $mapping, $index ) {
* @return void
*/
public function handle_update_synonyms() {
$nonce = filter_input( INPUT_POST, $this->get_nonce_field(), FILTER_SANITIZE_STRING );
$referer = filter_input( INPUT_POST, '_wp_http_referer', FILTER_SANITIZE_STRING );
$nonce = filter_input( INPUT_POST, $this->get_nonce_field(), FILTER_SANITIZE_SPECIAL_CHARS );
$referer = filter_input( INPUT_POST, '_wp_http_referer', FILTER_SANITIZE_URL );
$post_id = false;

if ( wp_verify_nonce( $nonce, $this->get_nonce_action() ) ) {
$synonyms = filter_input( INPUT_POST, $this->get_synonym_field(), FILTER_SANITIZE_STRING );
$mode = filter_input( INPUT_POST, 'synonyms_editor_mode', FILTER_SANITIZE_STRING );
$synonyms = filter_input( INPUT_POST, $this->get_synonym_field(), FILTER_CALLBACK, [ 'options' => 'wp_strip_all_tags' ] );
$mode = filter_input( INPUT_POST, 'synonyms_editor_mode', FILTER_SANITIZE_SPECIAL_CHARS );
$content = trim( sanitize_textarea_field( $synonyms ) );

// Content can't be empty.
Expand Down