Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion cleantalk.php
Original file line number Diff line number Diff line change
Expand Up @@ -2361,7 +2361,7 @@ function apbct_rc__insert_auth_key($key, $plugin)
require_once(ABSPATH . '/wp-admin/includes/plugin.php');

if ( is_plugin_active($plugin) ) {
$key = trim($key);
$key = trim($key, " \n\r\t\v\x00");

if ( $key && preg_match('/^[a-z\d]{3,30}$/', $key) ) {
$result = API::methodNoticePaidTill(
Expand Down
6 changes: 3 additions & 3 deletions inc/cleantalk-common.php
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@ function apbct_get_pixel_url($direct_call = false)
*/
function apbct_email_check_before_post()
{
$email = trim(TT::toString(Post::get('email')));
$email = trim(TT::toString(Post::get('email')), " \n\r\t\v\x00");

if ( $email ) {
$result = \Cleantalk\ApbctWP\API::methodEmailCheck($email);
Expand All @@ -762,7 +762,7 @@ function apbct_email_check_before_post()
function apbct_email_check_exist_post()
{
global $apbct;
$email = trim(TT::toString(Post::get('email')));
$email = trim(TT::toString(Post::get('email')), " \n\r\t\v\x00");
$api_key = $apbct->api_key;
$brandname = $apbct->data['wl_mode_enabled'] ? $apbct->data['wl_brandname'] : 'Anti-Spam by CleanTalk';
if ( $email && $api_key ) {
Expand Down Expand Up @@ -1152,7 +1152,7 @@ function ct_get_fields_any($arr, $email = '', $nickname = '')
foreach ( $nickname as $value ) {
$nickname_str .= ($value ? $value . " " : "");
}
$nickname = trim($nickname_str);
$nickname = trim($nickname_str, " \n\r\t\v\x00");
}

return ct_gfa($arr, TT::toString($email), TT::toString($nickname));
Expand Down
2 changes: 1 addition & 1 deletion inc/cleantalk-public-integrations.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ function ct_woocommerce_wishlist_check($args)
$subject = '';
$email = $args['wishlist_owner_email'];
if ( $args['wishlist_first_name'] !== '' || $args['wishlist_last_name'] !== '' ) {
$nickname = trim($args['wishlist_first_name'] . " " . $args['wishlist_last_name']);
$nickname = trim($args['wishlist_first_name'] . " " . $args['wishlist_last_name'], " \n\r\t\v\x00");
} else {
$nickname = '';
}
Expand Down
2 changes: 1 addition & 1 deletion inc/cleantalk-public.php
Original file line number Diff line number Diff line change
Expand Up @@ -982,7 +982,7 @@ function apbct_js_test($check_js_value = '', $is_cookie = false)
) {
$js_key = $is_cookie && $apbct->data['cookies_type'] === 'alternative'
? Cookie::get('ct_checkjs')
: trim($check_js_value);
: trim($check_js_value, " \n\r\t\v\x00");

// Check static key
if (
Expand Down
14 changes: 7 additions & 7 deletions inc/cleantalk-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -2450,7 +2450,7 @@ function apbct_settings__validate($incoming_settings)

$predefined_key = Constant::getValue(Constant::APBCT_SERVICE__SELF_OWNED_ACCESS_KEY, false);

$incoming_settings['apikey'] = ! empty($incoming_settings['apikey']) ? trim($incoming_settings['apikey']) : '';
$incoming_settings['apikey'] = ! empty($incoming_settings['apikey']) ? trim($incoming_settings['apikey'], " \n\r\t\v\x00") : '';
$incoming_settings['apikey'] = $predefined_key !== false ? $predefined_key : $incoming_settings['apikey'];
$incoming_settings['apikey'] = ! is_main_site() && $apbct->white_label && $apbct->settings['apikey'] ? $apbct->settings['apikey'] : $incoming_settings['apikey'];
$incoming_settings['apikey'] = is_main_site() || $apbct->allow_custom_key || $apbct->white_label ? $incoming_settings['apikey'] : $apbct->network_settings['apikey'];
Expand All @@ -2470,7 +2470,7 @@ function apbct_settings__validate($incoming_settings)
// Sanitize setting values
foreach ( $incoming_settings as &$setting ) {
if ( is_string($setting) ) {
$setting = preg_replace('/[<"\'>]/', '', trim($setting));
$setting = preg_replace('/[<"\'>]/', '', trim($setting, " \n\r\t\v\x00"));
} // Make HTML code inactive
}

Expand Down Expand Up @@ -2666,7 +2666,7 @@ function apbct_settings__validate($incoming_settings)
// compare non-main site blog key with the validating key
$blog_settings = get_option('cleantalk_settings');
$key_from_blog_settings = !empty($blog_settings['apikey']) ? $blog_settings['apikey'] : '';
if ( isset($incoming_settings['apikey']) && (trim($incoming_settings['apikey']) !== trim($key_from_blog_settings)) ) {
if ( isset($incoming_settings['apikey']) && (trim($incoming_settings['apikey'], " \n\r\t\v\x00") !== trim($key_from_blog_settings, " \n\r\t\v\x00")) ) {
$blog_key_changed = true;
}
$apbct->data['key_changed'] = empty($blog_key_changed) ? false : $blog_key_changed;
Expand Down Expand Up @@ -2910,7 +2910,7 @@ function apbct_settings__save_key($apikey = '', $direct_call = false)
}
}

$apikey = trim($apikey);
$apikey = trim($apikey, " \n\r\t\v\x00");
$apikey = preg_match('/^[a-z\d]*$/', $apikey) ? $apikey : $apbct->settings['apikey'];

if ( APBCT_WPMS && ! is_main_site() && (int) $apbct->network_settings['multisite__work_mode'] === 2 ) {
Expand Down Expand Up @@ -3024,8 +3024,8 @@ function apbct_settings__get_key_auto($direct_call = false)
}

if ( ! empty($result['auth_key']) && apbct_api_key__is_correct($result['auth_key']) ) {
$apbct->data['key_changed'] = trim($result['auth_key']) !== $apbct->settings['apikey'];
$apbct->settings['apikey'] = trim($result['auth_key']);
$apbct->data['key_changed'] = trim($result['auth_key'], " \n\r\t\v\x00") !== $apbct->settings['apikey'];
$apbct->settings['apikey'] = trim($result['auth_key'], " \n\r\t\v\x00");
}

$templates = '';
Expand Down Expand Up @@ -3187,7 +3187,7 @@ function apbct_settings__sanitize__exclusions($exclusions, $regexp = false, $url
foreach ($exclusions as $exclusion) {
//Cut exclusion if more than 128 symbols gained
$sanitized_exclusion = substr($exclusion, 0, 128);
$sanitized_exclusion = trim($sanitized_exclusion);
$sanitized_exclusion = trim($sanitized_exclusion, " \n\r\t\v\x00");

if ( ! empty($sanitized_exclusion) ) {
if ( $regexp ) {
Expand Down
4 changes: 2 additions & 2 deletions inc/cleantalk-wpcli.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ public function create($args, $params)
}

if (isset($result['data']) && !empty($result['data']['auth_key']) && apbct_api_key__is_correct($result['data']['auth_key'])) {
$apbct->data['key_changed'] = trim($result['data']['auth_key']) !== $apbct->settings['apikey'];
$apbct->settings['apikey'] = trim($result['data']['auth_key']);
$apbct->data['key_changed'] = trim($result['data']['auth_key'], " \n\r\t\v\x00") !== $apbct->settings['apikey'];
$apbct->settings['apikey'] = trim($result['data']['auth_key'], " \n\r\t\v\x00");
$apbct->api_key = $apbct->settings['apikey'];
$this->prompt(__('Api key installed: ', 'cleantalk-spam-protect') . $apbct->settings['apikey']);
}
Expand Down
8 changes: 4 additions & 4 deletions lib/Cleantalk/Antispam/Integrations/AmemberRegister.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ public function getDataForChecking($argument)

$form_data = array();
$form_data['email'] = isset($_POST['email']) && is_string($_POST['email'])
? trim($_POST['email'])
? trim($_POST['email'], " \n\r\t\v\x00")
: '';
$form_data['username'] = isset($_POST['login']) && is_string($_POST['login'])
? trim($_POST['login'])
? trim($_POST['login'], " \n\r\t\v\x00")
: '';
if ( ! empty($_POST['name_f']) && is_string($_POST['name_f']) ) {
$form_data['first_name'] = trim($_POST['name_f']);
$form_data['first_name'] = trim($_POST['name_f'], " \n\r\t\v\x00");
}
if ( ! empty($_POST['name_l']) && is_string($_POST['name_l']) ) {
$form_data['last_name'] = trim($_POST['name_l']);
$form_data['last_name'] = trim($_POST['name_l'], " \n\r\t\v\x00");
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/Cleantalk/Antispam/Integrations/BookingCalendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ private function extractFieldByPattern(array $parsed_formdata, $pattern, $expect
{
foreach ($parsed_formdata as $key => $field) {
if (preg_match($pattern, $key)) {
$value = isset($field['value']) ? trim($field['value']) : '';
$value = isset($field['value']) ? trim($field['value'], " \n\r\t\v\x00") : '';
$type = isset($field['type']) ? $field['type'] : '';

// If type filter specified, check it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function getDataForChecking($argument)
return null;
}

$form_data['username'] = isset($_POST['username']) && is_string($_POST['username']) ? trim($_POST['username']) : '';
$form_data['username'] = isset($_POST['username']) && is_string($_POST['username']) ? trim($_POST['username'], " \n\r\t\v\x00") : '';
$form_data['email'] = isset($_POST['email']) ? $_POST['email'] : '';
if ( ! empty($_POST['first_name']) ) {
$form_data['first_name'] = $_POST['first_name'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ public function doPrepareActions($argument)
// first call in the flow - collect data for further instance calling
$comment_data = wp_unslash($_POST);
$comment_content = TT::getArrayValueAsString($comment_data, 'comment');
$comment_author = trim(strip_tags(TT::getArrayValueAsString($comment_data, 'author')));
$comment_author_email = trim(TT::getArrayValueAsString($comment_data, 'email'));
$comment_author_url = trim(TT::getArrayValueAsString($comment_data, 'url'));
$comment_author = trim(strip_tags(TT::getArrayValueAsString($comment_data, 'author')), " \n\r\t\v\x00");
$comment_author_email = trim(TT::getArrayValueAsString($comment_data, 'email'), " \n\r\t\v\x00");
$comment_author_url = trim(TT::getArrayValueAsString($comment_data, 'url'), " \n\r\t\v\x00");

$user = function_exists('apbct_wp_get_current_user') ? apbct_wp_get_current_user() : null;

Expand Down
2 changes: 1 addition & 1 deletion lib/Cleantalk/Antispam/Integrations/ElementorPro.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function getDataForChecking($argument)
foreach ( $matches as $match ) {
$sender_nickname .= isset($match[0]) && isset($form_data[$match[0]]) ? $form_data[$match[0]] . ' ' : '';
}
$sender_nickname = trim($sender_nickname);
$sender_nickname = trim($sender_nickname, " \n\r\t\v\x00");
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions lib/Cleantalk/Antispam/Integrations/ElfsightForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ public function getDataForChecking($argument)
if (!is_object($field) || !isset($field->name)) {
continue;
}
$value = isset($field->value) ? (is_string($field->value) ? trim($field->value) : $field->value) : '';
$name = mb_strtolower(trim($field->name));
$value = isset($field->value) ? (is_string($field->value) ? trim($field->value, " \n\r\t\v\x00") : $field->value) : '';
$name = mb_strtolower(trim($field->name, " \n\r\t\v\x00"));

if (strpos($name, 'first') !== false && strpos($name, 'name') !== false) {
$result['nickname'] = $value;
Expand Down
4 changes: 2 additions & 2 deletions lib/Cleantalk/Antispam/Integrations/Forminator.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function getDataForChecking($argument)
}
// First non-empty email-* — empty email-2/3 from hidden multi-step pages must not win.
if (is_string($key) && strpos($key, 'email-') === 0) {
$candidate = trim(str_replace(' ', '', TT::toString($value)));
$candidate = trim(str_replace(' ', '', TT::toString($value)), " \n\r\t\v\x00");
if ($candidate !== '' && $email === '') {
$email = $candidate;
}
Expand All @@ -38,7 +38,7 @@ public function getDataForChecking($argument)
is_array($tmp_data['emails_array'])
) {
foreach ($tmp_data['emails_array'] as $emails_array_value) {
$candidate = trim(str_replace(' ', '', TT::toString($emails_array_value)));
$candidate = trim(str_replace(' ', '', TT::toString($emails_array_value)), " \n\r\t\v\x00");
if ($candidate !== '') {
$email = $candidate;
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function getDataForChecking($argument)
$userdata = explode(";", TT::toString(Request::get('userdata')));
$parsed_userdata = [];
foreach ($userdata as $_user) {
$parsed_userdata[] = strip_tags(wfu_plugin_decode_string(trim(substr($_user, 1))));
$parsed_userdata[] = strip_tags(wfu_plugin_decode_string(trim(substr($_user, 1), " \n\r\t\v\x00")));
}

$input_array = apply_filters('apbct__filter_post', $parsed_userdata);
Expand Down
2 changes: 1 addition & 1 deletion lib/Cleantalk/Antispam/IntegrationsByClass/WPForms.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public function gatherData($entry, $form)

// add unique key if key exist
if ($field_label) {
$field_label = mb_strtolower(trim($field_label));
$field_label = mb_strtolower(trim($field_label, " \n\r\t\v\x00"));
$field_label = str_replace(' ', '_', $field_label);
$field_label = preg_replace('/\W/u', '', $field_label);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function apbctFormSearchAddFields($form_html)
preg_match('/form.*method="(.*?)"/', $form_html, $matches);
$method = empty($matches[1])
? 'get'
: trim($matches[1]);
: trim($matches[1], " \n\r\t\v\x00");
}
$form_method = strtolower($method);
$form_sign = sprintf(
Expand Down
2 changes: 1 addition & 1 deletion lib/Cleantalk/ApbctWP/ContactsEncoder/ContactsEncoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ public static function getPhonesEncodingLongDescription()
<p>%s</p>
';
$tmp = sprintf(
trim($tmp),
trim($tmp, " \n\r\t\v\x00"),
__('Enable this option to encode contact phone numbers', 'cleantalk-spam-protect'),
__('There are a few requirements to the number format:', 'cleantalk-spam-protect'),
__('Should starting with "+" symbol or opening brace', 'cleantalk-spam-protect'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ private function appendCardCssChunk($css)
return;
}

$css = trim($css);
$css = trim($css, " \n\r\t\v\x00");

if ( $css === '' ) {
return;
Expand Down Expand Up @@ -454,7 +454,7 @@ private function mergeCardCssChunks($chunks)
continue;
}

$chunk = trim($chunk);
$chunk = trim($chunk, " \n\r\t\v\x00");

if ( $chunk !== '' ) {
$merged[] = $chunk;
Expand All @@ -463,15 +463,15 @@ private function mergeCardCssChunks($chunks)

if ( $merged === array() ) {
return $this->isCardCssChunk($this->card_inline_css)
? trim($this->card_inline_css)
? trim($this->card_inline_css, " \n\r\t\v\x00")
: '';
}

if (
$this->card_inline_css !== ''
&& $this->isCardCssChunk($this->card_inline_css)
) {
$merged[] = trim($this->card_inline_css);
$merged[] = trim($this->card_inline_css, " \n\r\t\v\x00");
}

return implode("\n", array_unique($merged));
Expand Down Expand Up @@ -626,7 +626,7 @@ private function readCssFromSrc($url)
return '';
}

return trim($css);
return trim($css, " \n\r\t\v\x00");
}

/**
Expand Down Expand Up @@ -668,7 +668,7 @@ private function extractCardCssFromHtml($content)
continue;
}

$css = trim($css);
$css = trim($css, " \n\r\t\v\x00");

if ( $css !== '' ) {
$chunks[] = $css;
Expand Down Expand Up @@ -713,7 +713,7 @@ private function collectInlineCssFromQueue()

foreach ( $data as $piece ) {
if ( is_string($piece) && $this->isCardCssChunk($piece) ) {
$chunks[] = trim($piece);
$chunks[] = trim($piece, " \n\r\t\v\x00");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ protected function removeDuplicateContactsOutsideShortcodes($title)

$protected_contacts = array();
foreach ( $matches[1] as $inner_match ) {
$inner = trim($inner_match[0]);
$inner = trim($inner_match[0], " \n\r\t\v\x00");
if ( $inner !== '' ) {
$protected_contacts[$inner] = true;
}
Expand All @@ -613,7 +613,7 @@ protected function removeDuplicateContactsOutsideShortcodes($title)

$result .= $this->stripProtectedContactsFromPlainText(substr($title, $offset), array_keys($protected_contacts));

return trim(preg_replace('/\s+/', ' ', $result));
return trim(preg_replace('/\s+/', ' ', $result), " \n\r\t\v\x00");
}

/**
Expand Down Expand Up @@ -911,7 +911,7 @@ public function processTitleString($title, $strip_html = true)

if ( $strip_html ) {
$result = wp_strip_all_tags($result);
$result = trim(preg_replace('/\s+/', ' ', $result));
$result = trim(preg_replace('/\s+/', ' ', $result), " \n\r\t\v\x00");
}

return $result;
Expand All @@ -929,7 +929,7 @@ public static function stripShortcodesForSlug($title)
$title = preg_replace('/\[apbct_skip_encoding\](.*?)\[\/apbct_skip_encoding\]/s', '$1', $title);
$title = preg_replace('/\[\/?apbct_skip_encoding\]/', '', $title);

return trim(preg_replace('/\s+/', ' ', $title));
return trim(preg_replace('/\s+/', ' ', $title), " \n\r\t\v\x00");
}

/**
Expand Down
4 changes: 2 additions & 2 deletions lib/Cleantalk/ApbctWP/Cron.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ public function getTasks()
}

$unserialize_options = array('allowed_classes' => false);
$unserialized = @unserialize(trim($result), $unserialize_options);
$unserialized = @unserialize(trim($result, " \n\r\t\v\x00"), $unserialize_options);

if ( is_string($unserialized) && is_serialized($unserialized) ) {
$unserialized = @unserialize(trim($unserialized), $unserialize_options);
$unserialized = @unserialize(trim($unserialized, " \n\r\t\v\x00"), $unserialize_options);
}

return is_array($unserialized) ? $unserialized : array();
Expand Down
4 changes: 2 additions & 2 deletions lib/Cleantalk/ApbctWP/FindSpam/CommentsChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ private static function removeSkipRoles(array $comments, array $skip_roles)
private static function removeCommentsWithoutIPEmail(array $comments)
{
foreach ($comments as $index => $comment) {
$comment_ip = ! empty($comment->comment_author_IP) ? trim($comment->comment_author_IP) : false;
$comment_email = ! empty($comment->comment_author_email) ? trim($comment->comment_author_email) : false;
$comment_ip = ! empty($comment->comment_author_IP) ? trim($comment->comment_author_IP, " \n\r\t\v\x00") : false;
$comment_email = ! empty($comment->comment_author_email) ? trim($comment->comment_author_email, " \n\r\t\v\x00") : false;

// Validate IP and Email
$comment_ip = filter_var($comment_ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4);
Expand Down
2 changes: 1 addition & 1 deletion lib/Cleantalk/ApbctWP/FindSpam/UsersChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ private static function removeUsersWithoutIPEmail(array $users)
? $ip_from_keeper
: false;
$user_ip = $ip_from_keeper;
$user_email = ! empty($user->user_email) ? trim($user->user_email) : false;
$user_email = ! empty($user->user_email) ? trim($user->user_email, " \n\r\t\v\x00") : false;

// Validate IP and Email
$user_ip = filter_var($user_ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4);
Expand Down
2 changes: 1 addition & 1 deletion lib/Cleantalk/ApbctWP/Firewall/SFW.php
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ public static function sendLog($db, $log_table, $ct_key)
$ids_invalid = array();
$data = array();
foreach ($logs as $_key => &$value) {
$ip = isset($value['ip']) ? trim((string)$value['ip']) : '';
$ip = isset($value['ip']) ? trim((string)$value['ip'], " \n\r\t\v\x00") : '';

// Do not send empty/invalid IPs — they break cloud collectors.
if ( Helper::ipValidate($ip) === false ) {
Expand Down
Loading
Loading