Skip to content

Commit c421e4f

Browse files
committed
Add a ValueError for content-type field
1 parent 7bfbc5c commit c421e4f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Lib/gettext.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,10 @@ def _parse(self, fp):
407407
elif lastk:
408408
self._info[lastk] += '\n' + item
409409
if k == 'content-type':
410-
self._charset = v.split('charset=')[1]
410+
try:
411+
self._charset = v.split('charset=')[1]
412+
except IndexError:
413+
raise ValueError(f"invalid content-type syntax: '{v}'. Expected 'charset='.") from None
411414
elif k == 'plural-forms':
412415
v = v.split(';')
413416
try:

0 commit comments

Comments
 (0)