Skip to content

Commit de1461d

Browse files
author
Benjamin Moody
committed
Record.check_field: sig_name strings may contain whitespace.
It is permitted and not unheard of for signal name strings to contain space characters. This should be allowed, provided that the string does not start or end with a space. All control characters should be disallowed.
1 parent 7f9cd47 commit de1461d

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

wfdb/io/record.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -520,9 +520,15 @@ def check_field(self, field, required_channels="all"):
520520
"block_size values must be non-negative integers"
521521
)
522522
elif field == "sig_name":
523-
if re.search(r"\s", item[ch]):
523+
if item[ch][:1].isspace() or item[ch][-1:].isspace():
524+
raise ValueError(
525+
"sig_name strings may not begin or end with "
526+
"whitespace."
527+
)
528+
if re.search(r"[\x00-\x1f\x7f-\x9f]", item[ch]):
524529
raise ValueError(
525-
"sig_name strings may not contain whitespaces."
530+
"sig_name strings may not contain "
531+
"control characters."
526532
)
527533
if len(set(item)) != len(item):
528534
raise ValueError("sig_name strings must be unique.")

0 commit comments

Comments
 (0)