Skip to content

Barcode::isbn13() can generate ISMN codes (prefix 9790) #1051

@Hikingyo

Description

@Hikingyo

Bug description

Faker\Core\Barcode::isbn13() can produce barcodes starting with 9790,
which is the reserved prefix for ISMN (International Standard Music Number),
not ISBN-13.

Root cause

The current implementation picks randomly between prefix 978 and 979,
then appends 9 fully random digits. When the prefix is 979 and the first
appended digit is 0, the result passes EAN-13 checksum validation but is
not a valid ISBN-13.

Expected behavior

isbn13() should only produce codes with prefix 978 or 97919799.

Steps to reproduce

Call isbn13() a large number of times and check if any result starts with 9790.

Valid ISBN-13 prefixes

Prefix Valid?
978 + 9d ✅ ISBN-13
97919799 + 8d ✅ ISBN-13
9790 + 8d ❌ ISMN

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions