mrz-java icon indicating copy to clipboard operation
mrz-java copied to clipboard

Check-digit fails for document numbers with more than 9 characters

Open jcandelaria-exiger opened this issue 2 months ago • 1 comments

Hello, ran into an issue parsing a TD1 document. Example:

I<SWEHVC8N3QW7<ZE17422<<<<<<<< 8104199F3012257SWE<<<<<<<<<<<9 IECGDQB<<MMHQQ<<<<<<<<<<<<<<<<

According to the specifications for TD1 Size, if the document number is longer than 9 characters, the check digit will contain a '<' to indicate the number continues. Then the optional section will contain the rest of the number, followed by a check digit.

Currently, the checkDigit method in MrzParser takes the filler character as a 0 and then continues as normal, causing the digit check to fail. (https://github.com/ZsBT/mrz-java/blob/master/src/main/java/com/innovatrics/mrz/MrzParser.java#L159)

The logic should be that if there is a filler character, it should first get the whole document number and calculate the check digit from the full number.

Reference: www.icao.int/sites/default/files/publications/DocSeries/9303_p5_cons_en.pdf Part 5. Specifications for TD1 Size Note j

jcandelaria-exiger avatar Oct 02 '25 14:10 jcandelaria-exiger