Skip to content

Commit

Permalink
🐛 Improve is_legal_header_name
Browse files Browse the repository at this point in the history
fix issue #41
  • Loading branch information
Ousret committed Jan 27, 2021
1 parent d381049 commit 6128b6c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion kiss_headers/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,10 +379,18 @@ def is_legal_header_name(name: str) -> bool:
False
>>> is_legal_header_name("Hello \\tWorld")
False
>>> is_legal_header_name('Hello World"')
False
>>> is_legal_header_name("Hello World/")
True
>>> is_legal_header_name("\x00")
False
>>> is_legal_header_name("\x07")
False
"""
return (
name != ""
and search(r"[^\x00-\x7F]|[:;(),<>=@?\[\]\r\n\t &{}\\]", name) is None
and search(r"[^\x21-\x7F]|[:;(),<>=@?\[\]\r\n\t &{}\"\\]", name) is None
)


Expand Down

0 comments on commit 6128b6c

Please sign in to comment.