Sanitize artifact ID input to hex-only characters

- Convert input to lowercase
- Strip non-hex characters (a-f, 0-9 only)
- Limit to 64 characters (SHA256 length)
- Show character count in validation hint
This commit is contained in:
Mondo Diaz
2026-01-07 14:37:44 -06:00
parent 0302e5b21a
commit 72e988dda1

View File

@@ -365,7 +365,7 @@ function PackagePage() {
<input
type="text"
value={artifactIdInput}
onChange={(e) => setArtifactIdInput(e.target.value)}
onChange={(e) => setArtifactIdInput(e.target.value.toLowerCase().replace(/[^a-f0-9]/g, '').slice(0, 64))}
placeholder="Enter SHA256 artifact ID (64 hex characters)"
className="artifact-id-input"
/>
@@ -383,7 +383,7 @@ function PackagePage() {
</a>
</div>
{artifactIdInput.length > 0 && artifactIdInput.length !== 64 && (
<p className="validation-hint">Artifact ID must be exactly 64 hex characters</p>
<p className="validation-hint">Artifact ID must be exactly 64 hex characters ({artifactIdInput.length}/64)</p>
)}
</div>