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
10 changes: 8 additions & 2 deletions lib/Cleantalk/ApbctWP/ContactsEncoder/ContactsEncoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -320,22 +320,28 @@ public static function getPhonesEncodingLongDescription()
<p class="apbct-icon-ok" style="padding-left: 10px">%s</p>
<p class="apbct-icon-ok" style="padding-left: 10px">%s</p>
<p class="apbct-icon-ok" style="padding-left: 10px">%s</p>
<p class="apbct-icon-ok" style="padding-left: 10px">%s</p>
<p class="apbct-icon-ok" style="padding-left: 10px">%s</p>
<p class="apbct-icon-ok" style="padding-left: 10px">%s</p>
<p>%s</p>
<p>%s</p>
';
$tmp = sprintf(
$tmp,
trim($tmp),
__('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'),
__('At least 8 digit numbers', 'cleantalk-spam-protect'),
__('Less than 13 digit numbers', 'cleantalk-spam-protect'),
__('Spaces, braces and dashes between digits are allowed', 'cleantalk-spam-protect'),
__('Spaces, braces, dots and dashes between digits are allowed', 'cleantalk-spam-protect'),
__('Examples of format', 'cleantalk-spam-protect'),
esc_html('+1 (234) 567-8901'),
esc_html('+12345678901'),
esc_html('+12 34 5678901'),
esc_html('(234) 567-8910'),
esc_html('+49 30 1234567'),
esc_html('+49.30.1234567'),
esc_html('+1.775.333.3330'),
__('Complied numbers in the "a" tag with "tel" property will be also encoded', 'cleantalk-spam-protect'),
esc_html('<a href="tel:+11234567890">Call +1 (123) 456-7890</a>')
);
Expand Down
1 change: 0 additions & 1 deletion lib/Cleantalk/Common/ContactsEncoder/ContactsEncoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ public function runDecoding($encoded_contacts_data)

/**
* @param string $content
* @param bool $skip_exclusions
*
* @return string
* @psalm-suppress PossiblyUnusedReturnValue
Expand Down
31 changes: 31 additions & 0 deletions tests/ApbctWP/ContactsEncoder/TestContactsEncoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,21 @@ public function testPlainTextEncodeDecodeSSL()
$this->assertEquals($decoded_entity, $this->plain_text);
}

public function testPlainTextDecodeError()
{
$decoded_entity = $this->contacts_encoder->encoder->decodeString('asdas121312');
$this->assertEmpty($decoded_entity);
$this->assertIsString($decoded_entity);
/**
* @var State $apbct
*/
global $apbct;
$this->assertTrue($apbct->isHaveErrors());
$this->assertTrue($apbct->errorExists('email_encoder'), $this->plain_text);
$this->assertStringContainsString( 'decrypt attempts failed', $apbct->errors['email_encoder'][0]['error']);
$apbct->errorDeleteAll();
}

public function testEncodeErrors()
{
/**
Expand Down Expand Up @@ -164,16 +179,24 @@ public function testEncodingPhoneNumbers()
'+7 123 456 78 90',
'+71234567890',
'(999) 321-1233',
'+1.775.301.1130',
'+49.30.123.4567',
'+49.30.1234567',
);

$test_stack_skip_to = array(
'192.168.2.1',
'prefix.1.775.301.1130.postfix',
'prefix.+1.225.201.113.postfix',
'+1.225.201.112ss',
'+1.225.201.112',
'8.168.2.1',
'81.234.56.78',
'71234567890',
'+7413033',
'+7(413)033',
'+7 (413) 03 3',
'+49.30.1.234567',
);

$regexp_for_blur = '/.+data-original-string=[\s\S]+apbct-email-encoder[\s\S]+browser\.[\"\']>[\s\S]+apbct-blur[\s\S]+\*?\*+<\/span>[\s\S]+/';
Expand Down Expand Up @@ -220,4 +243,12 @@ public function testPhoneEncodingSetting()
$this->assertEquals($test_tel_origin, $result);
}

public function testGetPhonesEncodingLongDescription()
{
$description = ContactsEncoder::getPhonesEncodingLongDescription();
$this->assertIsString($description);
$this->assertStringStartsWith('<', $description);
$this->assertStringEndsWith('>', $description);
}

}