Last modified: 2014-11-17 10:35:24 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T4391, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 2391 - Implement a validation check for ISBN links
Implement a validation check for ISBN links
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
Parser (Other open bugs)
unspecified
All All
: Lowest enhancement with 7 votes (vote)
: ---
Assigned To: Ævar Arnfjörð Bjarmason
http://en.wikipedia.org/wiki/ISBN
: need-parsertest, parser, patch, patch-need-review
Depends on:
Blocks: 29473
  Show dependency treegraph
 
Reported: 2005-06-11 16:30 UTC by Ævar Arnfjörð Bjarmason
Modified: 2014-11-17 10:35 UTC (History)
8 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments
ISO 2108:1992, revision of third edition (draft) (135.38 KB, application/pdf)
2005-06-11 19:52 UTC, Ævar Arnfjörð Bjarmason
Details
Adds new isValidISBN function to SpecialBooksources (1.10 KB, patch)
2008-04-29 03:21 UTC, Matthew Flaschen
Details

Description Ævar Arnfjörð Bjarmason 2005-06-11 16:30:28 UTC
Currently we detect ISBN links by looking for strings like (regex) "ISBN
([0123456789-Xx]+) in the text and work with that. However the ISBN standard
comes with a built in checksum algorithm that allows one to see if the number in
question is actually a conforming number or just a bunch of gibberish.

We should check if that's the case (gibberish) and not give it the special "ISBN
treatment"

The algorithm is as follows:

# 1. Take an ISBN number like ISBN 0-596-00287-4 (for [[Free as in Freedom]])
# 2. Split the numbers into the ISBN number and the check digit (0-596-00287 and 4)
# 4. Multiply each ISBN digit by its place in the number sequance (nondigits
omitted)  counting from 1
# if (1*0 + 2*5 + 3*9 + 4*6 + 5*0 + 6*0 + 7*2 + 8*8 + 9*7) mod 11 = 4 (the check
digit) the number is valid, else it's invalid.
Comment 1 Ævar Arnfjörð Bjarmason 2005-06-11 19:52:10 UTC
Created attachment 602 [details]
ISO 2108:1992, revision of third edition (draft)
Comment 2 Ævar Arnfjörð Bjarmason 2005-06-13 17:45:20 UTC
Moved the severity back to minor since this is not really an enhancement, we
currently accept invalid ISBN links and are thus not ISO 2108 conforming.
Comment 3 lɛʁi לערי ריינהארט 2008-02-03 21:32:51 UTC
Beside 10 digit ISBN numbers the validation should handle also 13 digit ISBN numbers.

Best regards Reinhardt [[user:Gangleri]]
Comment 4 Matthew Flaschen 2008-04-29 03:21:04 UTC
Created attachment 4848 [details]
Adds new isValidISBN function to SpecialBooksources
Comment 5 Matthew Flaschen 2008-04-29 03:23:55 UTC
I just attached a patch with a PHP function I wrote to do validation of both ISBN 10 and ISBN 13.  Now, this just needs to be called from an appropriate place, such as magicLinkCallback in Parser.php.

The ISBN validator is checked in isolation, but I have not yet attempted to integrate it.
Comment 6 Brion Vibber 2008-12-13 00:00:05 UTC
Committed in r44514 and now used to add a warning on Special:Booksources when given invalid input.

This could be called from the parser as well, but I'm a little hesitant just yet. Parser tests currently contain some bogus ISBN numbers which need to be replaced with legit ones... there's also the possibility that some books really are published with bad ISBNs... on the other hand, Amazon won't let you search for them. :)
Plus the feedback as you're hitting preview might be nice... but it's also not clear what's wrong -- that is, that it's an invalid number rather than that you just didn't do something right. Do we want better feedback?
Comment 7 Matthew Flaschen 2008-12-13 15:52:10 UTC
I think it would be nice to have in the parser as well.  How about the error "The checksum of this ISBN number is invalid."  Seems clear enough, and should not make people think their syntax is wrong. I don't think it's ideal for the parser to link broken numbers (and of course, tests should be fixed).
Comment 8 Brion Vibber 2008-12-15 01:00:01 UTC
Well, that might be pretty annoying if you're just trying to give a sample of ISBN formatting without actually intending to have a valid number... Could use <nowiki> there, but dunno if that's just going to be uglier than not. :(
Comment 9 Matthew Flaschen 2008-12-15 03:57:01 UTC
It takes about 15 seconds to find a valid ISBN to use as an example (Google [ISBN example]).  I don't see that as a reason not to have a warning.
Comment 10 Sam Reed (reedy) 2011-09-27 20:55:29 UTC
Comment on attachment 4848 [details]
Adds new isValidISBN function to SpecialBooksources

Marking as obsolete, code is already in core, and presumably has been for some time
Comment 11 Gabriel Wicke 2011-11-10 14:34:21 UTC
I also agree with Brion's hesitation to force all ISBN links to be valid in the parser. While it might give some welcome early feedback to editors it would also complicate other situations unnecessarily, so it is not clear to be a win overall.
Comment 12 Diederik van Liere 2011-11-13 01:35:56 UTC
Committed in https://www.mediawiki.org/wiki/Special:Code/MediaWiki/44514.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links