mercuriete / android-mrz-reader

MRZ camera reader
Apache License 2.0
46 stars 28 forks source link

PASSPORT_TD_3_LINE_2_REGEX bug #81

Closed smithaaron closed 2 years ago

smithaaron commented 2 years ago

The passport line 2 regex expects only a numeric character for the second last character of the MRZ. This is incorrect according to the spec (and my passport), which states "Check digit over digits 29–42 (may be < if all characters are <)". So the regex should be updated from

public static final String PASSPORT_TD_3_LINE_2_REGEX = "([A-Z0-9<]{9})([0-9]{1})([A-Z]{3})([0-9]{6})([0-9]{1})([M|F|X|<]{1})([0-9]{6})([0-9]{1})([A-Z0-9<]{14})([0-9]{1})([0-9]{1})";

to

public static final String PASSPORT_TD_3_LINE_2_REGEX = "([A-Z0-9<]{9})([0-9]{1})([A-Z]{3})([0-9]{6})([0-9]{1})([M|F|X|<]{1})([0-9]{6})([0-9]{1})([A-Z0-9<]{14})([0-9<]{1})([0-9]{1})";
mercuriete commented 2 years ago

I am using an external library for MRZ validation. https://sourceforge.net/p/jmrtd/code/HEAD/tree/

I will check it but I think I can't do anything with that.

I will leave this issue open a little bit.

PS1: the validation takes place in this line: https://github.com/mercuriete/android-mrz-reader/blob/b3dce8e0b7a5f42fb3f0b2a1cac909d18cd83ccb/MRZReader/src/main/java/com/mercuriete/mrz/reader/utils/MRZCheckUtil.java#L31

I do some workaround and then ask to MRZInfo constructor to calculate checksums I could implement the calculations by my own.. but I don't have time.

smithaaron commented 2 years ago

My apologies. I just realised I made a huge mistake.

I meant to post this bug on a completely different android MRZ project 🤦 https://github.com/alimertozdemir/EPassportNFCReader

mercuriete commented 2 years ago

@smithaaron No problem :)

mercuriete commented 2 years ago

@smithaaron maybe you want to check this repository https://github.com/mercuriete/ajmrtd2

It is a simple NFC reader copied from the original ajmrtd project.