Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BR-DE-20 Incorrect Validation #76

Closed
playunits opened this issue Apr 22, 2022 · 3 comments
Closed

BR-DE-20 Incorrect Validation #76

playunits opened this issue Apr 22, 2022 · 3 comments
Labels
bug Something isn't working

Comments

@playunits
Copy link

Validating a valid IBAN according results in a Failure with the BR-DE-20 Error Code.

The Problem is that in the Rule the modified IBAN is being converted to "xs:integer".
According to ISO/IEC 7064 in order to validate a IBAN it has to be converted to a decimal value e.g. "xs:decimal".

Example

IBAN: DE93420700240615192200

Incorrect Rule:

not(ram:TypeCode = '59') or matches(normalize-space(replace(ram:PayerPartyDebtorFinancialAccount/ram:IBANID, '([ \n\r\t\s])', '')), '^[A-Z]{2}[0-9]{2}[a-zA-Z0-9]{0,30}$') and xs:integer(string-join(for $cp in string-to-codepoints(concat(substring(normalize-space(replace(ram:PayerPartyDebtorFinancialAccount/ram:IBANID, '([ \n\r\t\s])', '')),5),upper-case(substring(normalize-space(replace(ram:PayerPartyDebtorFinancialAccount/ram:IBANID, '([ \n\r\t\s])', '')),1,2)),substring(normalize-space(replace(ram:PayerPartyDebtorFinancialAccount/ram:IBANID, '([ \n\r\t\s])', '')),3,2))) return (if($cp > 64) then $cp - 55 else $cp - 48),'')) mod 97 = 1

Results in false

Corrected Rule:

not(ram:TypeCode = '59') or matches(normalize-space(replace(ram:PayerPartyDebtorFinancialAccount/ram:IBANID, '([ \n\r\t\s])', '')), '^[A-Z]{2}[0-9]{2}[a-zA-Z0-9]{0,30}$') and xs:decimal(string-join(for $cp in string-to-codepoints(concat(substring(normalize-space(replace(ram:PayerPartyDebtorFinancialAccount/ram:IBANID, '([ \n\r\t\s])', '')),5),upper-case(substring(normalize-space(replace(ram:PayerPartyDebtorFinancialAccount/ram:IBANID, '([ \n\r\t\s])', '')),1,2)),substring(normalize-space(replace(ram:PayerPartyDebtorFinancialAccount/ram:IBANID, '([ \n\r\t\s])', '')),3,2))) return (if($cp > 64) then $cp - 55 else $cp - 48),'')) mod 97 = 1

Correctly results in true

Notice that the only changed element is from xs:integer to xs:decimal

Best Regards

Juri Scholz

@phax phax added the bug Something isn't working label Apr 22, 2022
@phax
Copy link
Collaborator

phax commented Apr 22, 2022

Thanks for pointing that out - that indeed sounds like a classical integer overflow

@bdewein
Copy link
Collaborator

bdewein commented May 31, 2022

which version of xslt/xpath are you using? we cannot reproduce the error with xslt/xpath 2.0, because type promotion to xs:decimal occurs automatically in xslt/xpath 2.0

@rkottmann
Copy link
Member

In addition the ISO Standard ISO/IEC 7064 does not make any statements on which variable types should be used. It only talks about calculation in the "decimal" system w.r.t to radix 10, which is not to be confused with a variable type named "decimal"

@bdewein bdewein closed this as completed in 5c1a0d9 Nov 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants