Repository navigation
Conversation
…p receipt extract_transaction_id_from_app_receipt discarded the ASN.1 tags of the receipt payload, the in-app array and the transaction id, so a malformed receipt could return an int or bytes transaction id, or None when the in-app container was not a SET. Require a SET for the payload and the in-app array and a UTF8String for the transaction id, as the Java and Node libraries do, and raise ValueError otherwise.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ReceiptUtility.extract_transaction_id_from_app_receiptdecoded the receipt payload, the in-app purchase receipt and the transaction identifier without looking at their ASN.1 types. A malformed receipt could therefore return anint(INTEGER transaction id),bytes(OCTET STRING) or a non-UTF8Stringstr, and a non-SET payload or in-app purchase receipt was reported as "no in-app purchases" (None) instead of a malformed receipt.This change checks that the payload and the in-app purchase receipt are SETs and that the transaction identifier is a UTF8String, and raises
ValueErrorotherwise. This matches the Java library (ASN1Set/ASN1UTF8Stringchecks) and the Node library (31/0ctag checks). Valid receipts, including the Xcode receipts in the test resources, are unaffected.Tests: added a positive test with a synthetic receipt whose transaction id is a UTF8String, a test that INTEGER, OCTET STRING and IA5String transaction ids raise
ValueError, and tests that an in-app purchase receipt or a receipt payload that is not a SET raisesValueError. The three negative tests fail on main (ValueError not raised) and pass with this change;python -m unittestpasses (405 tests).This change was drafted with Claude Code (claude-opus-5-5); the test results above are from the runs described.