Skip to content

Commit f184707

Browse files
authored
trim sha1
1 parent adc7151 commit f184707

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/Validator/Sha1.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,12 @@ protected function check(?string $key, &$value): void {
1818
if (is_array($value) || is_object($value))
1919
throw new \ExceptionToResponse\InvalidParameterException('Invalid ' . $key, $this->getCnMsg());
2020
$value = (string)$value;
21+
$value = str_replace([
22+
"\x08",
23+
"\x7F"
24+
], '', $value); // x08为退格字符 x7f为DEL字符
25+
$value = trim($value);
2126
if (! preg_match("/[0-9a-fA-F]{40}$/", $value))
2227
throw new \ExceptionToResponse\InvalidParameterException('Invalid ' . $key, $this->getCnMsg());
2328
}
24-
}
29+
}

0 commit comments

Comments
 (0)