Skip to content

Commit

Permalink
Encoding\DkimTagValue\Tag: Ignore missing base64 padding
Browse files Browse the repository at this point in the history
  • Loading branch information
alexrsagen committed Apr 26, 2024
1 parent 50ddf4b commit 88736a3
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/encoding/dkim_tag_value/tag.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?php namespace Obie\Encoding\DkimTagValue;
use Obie\Encoding\DkimTagValue;
use Obie\Log;
use Obie\Validation\SimpleValidator;

class Tag {
const REGEX_PART_HYPHENATED_WORD = '[a-z](?:[a-z0-9\\-]*[a-z0-9])?';
Expand Down Expand Up @@ -36,7 +35,7 @@ public function isValid(string $version = DkimTagValue::VERSION_DKIM1): bool {
Log::warning('DkimTagValue/Tag: invalid hyphenated-word value for DKIM1 tag "t="');
return false;
}
if ($this->name === 'p' && !SimpleValidator::isValid($this->value, SimpleValidator::TYPE_BASE64)) {
if ($this->name === 'p' && preg_match('/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}(?:==)?|[A-Za-z0-9+\/]{3}=?)?$/', $this->value) !== 1) {
Log::warning('DkimTagValue/Tag: invalid public key value for DKIM1 tag "p="');
return false;
}
Expand Down

0 comments on commit 88736a3

Please sign in to comment.