Skip to content

Isbn accepts ISMNs (printed-music numbers, prefix 979-0) as valid book numbers #455

Closed

Description

@matt-edmondson

What's wrong

Since #334 / PR #407, an ISBN-13 has to start with 978 or 979:

private static bool IsValidIsbn13(string s)
{
// An ISBN-13 is an EAN-13 in the Bookland range; any other prefix is a non-book barcode.
if (!s.StartsWith("978", StringComparison.Ordinal) && !s.StartsWith("979", StringComparison.Ordinal))
{
return false;
}
int sum = 0;
for (int i = 0; i < 13; i++)
{
char c = s[i];
if (c is < '0' or > '9')
{
return false;
}

But 979-0 is not an ISBN range. It is the prefix of the International Standard Music Number (ISMN), which identifies printed music: since 2008 every ISMN is a 13-digit EAN beginning 9790. ISBNs are allocated under 979 only from 979-8 and 979-1x. An ISMN carries a valid EAN-13 check digit, so it passes as an Isbn. This is the same kind of bug #334 fixed, a non-book code accepted on its prefix alone.

Reproduction (net10.0, HEAD 3c0cea7)

Isbn.TryCreate("979-0-2600-0043-8", out _); // true -> "9790260000438" (an ISMN for a printed score)
Isbn.TryCreate("9790060115615", out _);     // true (an ISMN)

Suggested fix / acceptance criteria

  • In IsValidIsbn13, reject values starting with 9790, while keeping 978 and the other 979 prefixes.
  • Update the XML docs on Isbn and IsIsbnAttribute, and the rules table in the package README.
  • Tests in IsbnTests: the two ISMNs above fail Create/TryCreate, and 979-10-90636-07-1 still validates.

Activity

  1. added
    bug
    on Oct 18, 2026
  2. matt-edmondson commented on Oct 18, 2026

    @matt-edmondson
    ContributorAuthor

    Triage

    • Category: Bug
    • Priority: Medium. A validation gap: Isbn accepts a real class of non-book EAN-13 codes (ISMNs, 9790…). Nothing crashes, but values that should be rejected get through. The fix is a single prefix check plus docs and tests.
    • Area / suggested assignment: Semantics.Strings.Identifiers (IsIsbnAttribute.IsValidIsbn13). Tests go in IsbnTests. Also update the package README's rules table.
    • Duplicates / related: Not a duplicate. It follows on from Isbn accepts any EAN-13 barcode: Isbn.Create("4006381333931") (a non-book product code) validates because the 978/979 prefix is never checked #334 (closed), which added the 978/979 prefix check but left the 979-0 ISMN range open.
    • In progress: No open PR references this issue.

    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions