镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Reject trailing characters in hashes and encoded values - #486

Merged
nandgator merged 1 commit into
python-validators:masterfrom
xiehuanyi:fix/complete-hash-encoding-matches-20261008
Oct 10, 2026
Merged

nandgator merged 1 commit into
python-validators:masterfrom
xiehuanyi:fix/complete-hash-encoding-matches-20261008

Conversation

@xiehuanyi

Copy link
Copy Markdown
Contributor

Hash and encoding validators accept a final newline because the $ regular expression anchor can match immediately before it. For example, sha256("a" * 64 + "\n") currently returns True, although the input contains a character outside the digest.

Use re.fullmatch() for the six digest validators and four encoding validators. This preserves the accepted alphabets, case handling, and padding rules while requiring the entire value to match. The regression tests cover trailing newlines, CRLF, spaces, and extra lines across all ten validators.

Validation: the new tests produced 10 failures on unmodified master; after the fix, all 935 tests pass. Ruff lint, formatting checks for the changed files, and the complete Pyright check pass with Python 3.14.6. No other interpreter versions were run locally.

Developed, reviewed, and tested with AI assistance.

Copilot AI balanced review requested due to automatic review settings October 8, 2026 10:52

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@nandgator
nandgator merged commit 4db9c17 into python-validators:master Oct 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants