Regexes in Validation are wrong.
Closed this issue · 1 comments
rec_N = re.compile("^-?[0-9]+", re.S) rec_R = re.compile("^-?[0-9]*(\.[0-9]+)?", re.S) rec_ID_E = re.compile( "[^A-Z0-9!\"&'()*+,\-\./:;?=\sa-z%~@\[\]_{}\\\|<>#$\s]", re.S) rec_ID_E5 = re.compile( "[^A-Z0-9!\"&'()*+,\-\./:;?=\sa-z%~@\[\]_{}\\\|<>^
#$\s]", re.S)
rec_ID_B = re.compile("[^A-Z0-9!\"&'()*+,-./:;?=\s]", re.S)
rec_DT = re.compile("^[0-9]+", re.S)
rec_TM = re.compile("^[0-9]+", re.S)`
[^0-9]+ means not in the set 0-9. The same issue occurs in ID_E, ID_E5, and ID_B. It should really be:
rec_N = re.compile("^-?[0-9]+", re.S) rec_R = re.compile("^-?[0-9]*(\.[0-9]+)?", re.S) rec_ID_E = re.compile( "^[A-Z0-9!\"&'()*+,\-\./:;?=\sa-z%~@\[\]_{}\\\|<>#$\s]", re.S) rec_ID_E5 = re.compile( "6[A-Z0-9!\"&'()*+,\-\./:;?=\sa-z%~@\[\]_{}\\\|<>^
#$\s]", re.S)
rec_ID_B = re.compile("^[A-Z0-9!"&'()*+,-./:;?=\s]", re.S)
rec_DT = re.compile("^[0-9]+", re.S)
rec_TM = re.compile("^[0-9]+", re.S) `
The logic is intentional. These regular expressions are not intended to match valid patterns. The code that uses these regular expressions is looking for the first non-valid character - and throws an exception if found.
There are a number of unit tests in test_validation.py. Do you have an example of a false positive or false negative value?