Commit 1d4d3d4
Support stripping hash type prefixes from checksum fields
**Feature:** Allow users to paste checksums with type prefixes like "sha256:abc123..."
which are automatically stripped before validation.
**Implementation:**
- Split on first colon (":") to separate prefix from hash value
- Strip any prefix before the colon (e.g., "md5:", "sha256:", "SHA-256:")
- Normalize hash: lowercase, remove whitespace and dashes
- Works with any prefix format - no hardcoded list
**Updated behavior:**
- MD5/SHA1 fields now accept hashes with or without prefixes
- Whitespace and dashes are now stripped (previously invalid)
- Increased max_length to 64 to accommodate prefixes
- Removed HTML5 pattern attribute (validates in clean method instead)
**Examples of supported formats:**
- "abc123..." (plain hash - still works)
- "md5:abc123..." (lowercase prefix)
- "SHA256:ABC123..." (uppercase prefix, normalized to lowercase)
- "sha-256:abc 123" (dashes in prefix, spaces in hash - all stripped)
**Tests:** Added 8 new tests covering:
- Various prefix formats (md5:, sha256:, SHA-256:)
- Uppercase hashes (normalized to lowercase)
- Whitespace and dashes (now stripped)
- Backwards compatibility (hashes without prefixes)
All 27 form tests pass.
🤖 Generated with [Claude Code](https://claude.ai/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>1 parent 4179f0f commit 1d4d3d4
2 files changed
+133
-20
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
67 | | - | |
| 67 | + | |
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
72 | | - | |
73 | | - | |
| 72 | + | |
74 | 73 | | |
75 | 74 | | |
76 | | - | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
77 | 79 | | |
78 | 80 | | |
79 | 81 | | |
80 | 82 | | |
81 | | - | |
| 83 | + | |
82 | 84 | | |
83 | 85 | | |
84 | 86 | | |
85 | 87 | | |
86 | | - | |
87 | | - | |
| 88 | + | |
88 | 89 | | |
89 | 90 | | |
90 | | - | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
91 | 95 | | |
92 | 96 | | |
93 | 97 | | |
| |||
108 | 112 | | |
109 | 113 | | |
110 | 114 | | |
111 | | - | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
112 | 120 | | |
113 | 121 | | |
114 | 122 | | |
115 | 123 | | |
116 | 124 | | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
117 | 130 | | |
118 | 131 | | |
119 | 132 | | |
| |||
132 | 145 | | |
133 | 146 | | |
134 | 147 | | |
135 | | - | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
136 | 153 | | |
137 | 154 | | |
138 | 155 | | |
139 | 156 | | |
140 | 157 | | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
141 | 163 | | |
142 | 164 | | |
143 | 165 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
212 | 212 | | |
213 | 213 | | |
214 | 214 | | |
215 | | - | |
216 | | - | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
217 | 218 | | |
218 | 219 | | |
219 | 220 | | |
220 | 221 | | |
221 | 222 | | |
222 | 223 | | |
223 | | - | |
224 | | - | |
225 | | - | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
226 | 227 | | |
227 | | - | |
228 | | - | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
229 | 231 | | |
230 | 232 | | |
231 | 233 | | |
232 | 234 | | |
233 | 235 | | |
234 | 236 | | |
235 | | - | |
236 | | - | |
237 | | - | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
238 | 240 | | |
239 | 241 | | |
240 | 242 | | |
| |||
327 | 329 | | |
328 | 330 | | |
329 | 331 | | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
0 commit comments