Skip to content

Commit

Permalink
Spf1: Improve logging messages
Browse files Browse the repository at this point in the history
  • Loading branch information
alexrsagen committed Apr 25, 2024
1 parent 8cfda4f commit 08032ee
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/encoding/spf1.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public static function decode(string $input, bool $strict = true): ?Record {
case self::QUALIFIER_NEUTRAL:
// assert that we have not already started decoding a directive
if ($directive !== null) {
Log::warning('Spf1: unexpected qualifier');
Log::warning(sprintf('Spf1: unexpected qualifier "%s" at position %d', $c, $position));
return null;
}
// create a new directive
Expand All @@ -89,7 +89,7 @@ public static function decode(string $input, bool $strict = true): ?Record {
$buf_key = $buf;
// assert that the key is a valid modifier name
if (preg_match('/^[a-z0-9\-_\.]+$/i', $buf_key) !== 1) {
Log::warning('Spf1: ');
Log::warning(sprintf('Spf1: invalid modifier name at position %d', $position));
return null;
}
// advance position by 1
Expand All @@ -98,7 +98,7 @@ public static function decode(string $input, bool $strict = true): ?Record {
$buf = MacroString::extractString($input, $position);
// assert that the buffer contains a valid macro-string
if ($buf === null) {
Log::warning('Spf1: invalid macro-string');
Log::warning(sprintf('Spf1: invalid macro-string at position %d', $position));
return null;
}
// append the modifier to the record
Expand All @@ -112,7 +112,7 @@ public static function decode(string $input, bool $strict = true): ?Record {
case ':':
// assert that the directive does not already have a mechanism set
if ($directive !== null && $directive->mechanism !== '') {
Log::warning('Spf1: double mechanism key');
Log::warning(sprintf('Spf1: double mechanism key at position %d', $position));
return null;
}
// store mechanism key in directive
Expand All @@ -123,11 +123,11 @@ public static function decode(string $input, bool $strict = true): ?Record {
$buf = MacroString::extractString($input, $position);
// assert that the buffer contains a valid macro-string
if ($buf === null) {
Log::warning('Spf1: invalid macro-string');
Log::warning(sprintf('Spf1: invalid macro-string at position %d', $position));
return null;
}
if ($position >= strlen($input)) {
Log::warning('Spf1: invalid domain-spec: ended before domain-end');
Log::warning(sprintf('Spf1: invalid domain-spec: ended before domain-end at position %d', $position));
return null;
}
if ($input[$position] === '.') {
Expand All @@ -144,7 +144,7 @@ public static function decode(string $input, bool $strict = true): ?Record {
$buf_key = $buf;
$buf = MacroString::extranctExpand($input, $position);
if ($buf === null) {
Log::warning('Spf1: invalid macro-expand');
Log::warning(sprintf('Spf1: invalid macro-expand at position %d', $position));
return null;
}
$buf = $buf_key . $buf;
Expand Down

0 comments on commit 08032ee

Please sign in to comment.