ISBN checking now correctly flags ISBNs with all same digits as invalid

This commit is contained in:
Kovid Goyal 2011-04-30 13:20:38 -06:00
parent 571f50be43
commit 75a43d9c1a

View File

@ -274,6 +274,9 @@ def check_isbn(isbn):
if not isbn: if not isbn:
return None return None
isbn = re.sub(r'[^0-9X]', '', isbn.upper()) isbn = re.sub(r'[^0-9X]', '', isbn.upper())
all_same = re.match(r'(\d)\1{9,12}$', isbn)
if all_same is not None:
return None
if len(isbn) == 10: if len(isbn) == 10:
return check_isbn10(isbn) return check_isbn10(isbn)
if len(isbn) == 13: if len(isbn) == 13: