Skip to content

Validate RGB hex string length before conversion - #1152

Open
GreedyC wants to merge 1 commit into
scanny:masterfrom
GreedyC:codex/validate-rgb-hex-length
Open

GreedyC wants to merge 1 commit into
scanny:masterfrom
GreedyC:codex/validate-rgb-hex-length

Conversation

@GreedyC

@GreedyC GreedyC commented Oct 2, 2026

Copy link
Copy Markdown

Summary

Require six characters in RGBColor.from_string() before converting the RGB components. Inputs such as 12345 and 00000000 currently produce a color instead of rejecting the invalid length.

This matches the existing six-character validation of ST_HexColorRGB. Uppercase and lowercase six-character values remain supported.

Fixes #1151.

Tests

  • Three invalid-length regressions fail before the guard and pass afterward; uppercase/lowercase controls pass.
  • Full unit suite: 2,704 passed on Python 3.12.
  • Behave acceptance suite: 973 scenarios / 2,914 steps passed.
  • Ruff lint and formatting pass for the changed files (Ruff 0.11.13). The formatter also normalizes an existing wrapped string in the same source file without changing its value.

Tests use pytest 8.4.1 and pyparsing 3.2.3. Latest pyparsing 3.3.3 blocks collection through deprecated calls in existing test helpers; no helper or dependency changes are included.

Repository-wide Ruff reports the same 95 diagnostics on the unmodified base and this branch (the diagnostic signatures match). The optional strict Pyright check is also not clean: 19,963 errors on the base and 19,956 on this branch. Neither is claimed as passing repository-wide.

AI assistance was used for this fix and tests.

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.

RGBColor.from_string silently accepts invalid hex string lengths

1 participant