Comments (8)
I understand why the revert. What I don't understand is the decision to truncate the first zero only. Why only the first 0?
According to EMVStandardTagType
, it seems that 5F2A
should have a length of 3, not 4. So the test expecting 840
is somewhat correct. However, for other tags, like 9F02
, the length is expected to be 12. So the data manipulation for PACKED_NUMERIC
is breaking that contract (since it returns a 11 digit number).
It seems that rather than dropping 1 leading zero, the unpackValue
should add/remove enough zeros to make the length of the value match with what is defined in the EMVTagType
.
from jpos.
Can you provide a Unit test? (see issue #315 for a recent example, feel free to add tests to that class)
from jpos.
from jpos.
Added more tests that highlight the dropping of the leading 0.
For certain elements, such as country or currency codes like as 5F2A
, dropping this zero does not change the meaning of the value.
However for other elements, such as transaction amounts like 9F02
, dropping the leading zero, changes the actual value from 000000000033
to 00000000033
(note the missing leading 0).
The relevant code seems to be if
condition (lines 409-411) within the BERTLVPackager.unpackValue
class:
case PACKED_NUMERIC:
case PACKED_NUMERIC_DATE_YYMMDD:
case PACKED_NUMERIC_TIME_HHMMSS:
uninterpretLength = getUninterpretLength(dataLength, bcdInterpreterLeftPaddedZero);
unpackedValue = bcdInterpreterLeftPaddedZero.uninterpret(tlvData, 0, uninterpretLength);
if (unpackedValue.length() > 1 && unpackedValue.charAt(0) == '0') {
unpackedValue = unpackedValue.substring(1);
}
value = new ISOField(subFieldNumber, unpackedValue);
break;
Is it a question of removing the if
condition?
from jpos.
Hi @ar . I noticed that you reverted the change for PACKED_NUMERIC
. As I had mentioned earlier, there are cases, like 9F02
where dropping a zero, changes the meaning of the value. Since the definition of the tag expects 12 digits, sometimes, we can expect to receive 11. Can you explain the reasoning behind this? Why only truncate the first 0 and not all of them? Or nothing at all?
from jpos.
I reverted because the change broke EMVTagSequenceTest.testPacking()
gives:
Unpack error ==> expected: <840> but was: <0840>
I believe the test case is correct.
from jpos.
What I don't understand is the decision to truncate the first zero only. Why only the first 0?
You just need one 0 to pad an odd-length number, such as the currency code 840. A number such as '0001' would be coded as just one byte '01', and we would just swallow the first '0' to return '1'.
from jpos.
Sorry I missed your second comment:
However, for other tags, like 9F02, the length is expected to be 12. So the data manipulation for PACKED_NUMERIC is breaking that contract (since it returns a 11 digit number).
That's a good point. Will check that.
from jpos.
Related Issues (20)
- ISOServer.dump ConcurrentModificationException
- Import Key with even parity fails with Parity Exception HOT 7
- NACChannel header should use hex2byte instead of hex2bcd HOT 1
- Allow to load environment properties from multiple files in `Q2` `-E` option. HOT 2
- Base24Channel is not escaping `ETX` bytes at send time. HOT 2
- BitMap seems to be mismatched HOT 5
- Bug of CheckFields.setConfiguration HOT 1
- Any good first issue? HOT 5
- The trailer is unable to sent from Jpos server to the source. HOT 4
- The trailer is not added to the JPOS response. HOT 2
- New POSCapability helper
- Add Q2 switch to exit on failed deploy HOT 7
- Memory Leak in TransactionManager's redeployed participants
- QMUX Sequencing Issue HOT 3
- SimpleKeyFile.getKeys() seems to load the key file for every key.
- Q2.deployElement doesn't write the destination file atomically, which can make the deploy polling to fail HOT 2
- using BERTLVAsciiHexPackager and AsciiHexInterpreter returns incorrect uninterpretLength HOT 5
- Channel Class that wraps the JMS objects HOT 1
- Help validate ARQC using JCESecurityModule HOT 4
- When two Q2 services are connected, the response content cannot be received. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jpos.