Repository navigation
Commit 389c804
fix: charset parser strips inner whitespace from quoted values
Adds one final .strip() after the quote-stripping chain in
_parse_charset so that Content-Type: ...; charset=" utf-8 " yields a
clean codec name. Python's codec registry happens to normalize
whitespace on lookup (so the end-to-end mojibake risk is currently
masked), but the parser should still return a clean value rather than
rely on codec leniency.
Test verifies _parse_charset directly (the unit-level contract) plus
an end-to-end smoke through Response.text.
The other "concerns" listed in the deferred-work entry (substring
false-positives, mismatched quotes, multi-charset directives) do not
actually fire on the current code, per the spec's analysis.
Closes deferred-work entry: "Charset parser robustness".
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent b64203c commit 389c804
2 files changed
Lines changed: 20 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
68 | 69 | | |
69 | 70 | | |
70 | 71 | | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
71 | 90 | | |
72 | 91 | | |
73 | 92 | | |
| |||
0 commit comments