Opened 7 years ago
Last modified 6 years ago
#1604 new enhancement
ISBN/ISSN sanity checking
| Reported by: | ajlyon | Owned by: | dstillman |
|---|---|---|---|
| Priority: | minor | Milestone: | |
| Component: | interface | Version: | |
| Keywords: | Cc: | ajlyon@… |
Attachments (2)
Change History (6)
Changed 7 years ago by ajlyon
comment:1 Changed 7 years ago by ajlyon
comment:2 Changed 7 years ago by ajlyon
- Cc ajlyon@… added
comment:3 Changed 6 years ago by ajlyon
- Reporter changed from dstillman to ajlyon
- Summary changed from ISBN sanity checking to ISBN/ISSN sanity checking
Wikipedia informs us that ISSNs also have a system of check digits. A very similar routine should be written to check them as well, if the proposed patch is to land on the trunk.
See also ticket #1606 for a related concern that might be addressed simultaneously.
comment:4 Changed 6 years ago by ajlyon
The new attachment handles ISSN as well as ISBN, and it generally is more pleasant to work with. I've also fixed a bug in the previous version's check digit handling.
If this can indeed be tied into a little exclamation point in the interface, and hopefully exposed to translators as well, that'd be great. In translators, this would be useful to distinguish ISBN from ISSN in some import formats that don't do so; RIS, perhaps?
I'm attaching (isbn.js) a basic function that will take an input string and try to identify and validate an ISBN-10 or ISBN-13 in it. Based on my testing, it should handle most of the variation we see in ISBN formatting, including spacing characters (hyphens, spaces) and prefixes (ISBN, etc.).
It returns a four-element array with two booleans, corresponding to whether it found a valid ISBN-10 and ISBN-13, and two strings, which will be set to the validated ISBN-10 and ISBN-13 if found.
The main limitation with the function right now is that it doesn't properly handle the fairly common case of multiple ISBNs in one field, which many databases give. It will correctly process the first ISBN, but the others will be ignored.