Skip to content

Commit b8ee9c7

Browse files
committed
Sanity-check the reference before parsing
1 parent 05f17d4 commit b8ee9c7

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

project/examples/handlers.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,10 @@ def import_generic_transaction(self, at, lt):
166166
return lt
167167

168168
def import_tmatch_transaction(self, at, lt):
169+
if len(at.reference) < 2: # To avoid indexerrors
170+
return None
171+
if at.reference[0:2] == "RF": # ISO references, our lookup won't work with them, even worse: there will be exceptions
172+
return None
169173
# In this example the last meaningful number (last number is checksum) of the reference is used to recognize the TransactionTag
170174
try:
171175
lt.tag = TransactionTag.objects.get(tmatch=at.reference[-2])

0 commit comments

Comments
 (0)