Special:BookSources: Correct validation of ISBNs containing X
authorKevin Israel <pleasestand@live.com>
Tue, 24 Jun 2014 07:14:24 +0000 (03:14 -0400)
committerUmherirrender <umherirrender_de.wp@web.de>
Wed, 1 Oct 2014 19:14:39 +0000 (19:14 +0000)
commit19473fa625e173505ec0244710e0d30d0bcb0bdc
treef4b36f7778380577986c651a7de277957506ac46
parent5ed380bed54570a45ace6cc6c86db1ed99eb838f
Special:BookSources: Correct validation of ISBNs containing X

PHP's "equal" (==) operator considers the integer 0 to be equal to
the string 'X', and when 'X' is converted to a number, it becomes 0.
Neither is desired here.

* Fail when an X is encountered while calculating the check digit.
  (X can only occur as the check digit of an ISBN-10.)
* Fixed the check digit comparisons by adding an explicit string cast.
* Used the "identical" operator to make it more obvious that no type
  juggling should take place during the comparisons.
* Added some test cases.
* Removed an outdated TODO.

Bug: 67021
Change-Id: I85f53c41f403a60340e9441757fe66b9764e623c
RELEASE-NOTES-1.25
includes/specials/SpecialBooksources.php
tests/phpunit/includes/specials/SpecialBooksourcesTest.php [new file with mode: 0644]