Skip to content

Commit

Permalink
fix: [qrcode extractor] fix image/screenshot tag
Browse files Browse the repository at this point in the history
  • Loading branch information
Terrtia committed Oct 2, 2024
1 parent 32761fb commit 4dbda59
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion bin/modules/QrCodeReader.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def extract_qrcode(self, path):
try:
decodeds = decode(image)
for decoded in decodeds:
qr_codes = True
if decoded.data:
contents.append(decoded.data.decode())
except ValueError as e:
Expand All @@ -76,6 +77,7 @@ def extract_qrcode(self, path):
data_qr, box, qrcode_image = detector.detectAndDecode(image)
if data_qr:
contents.append(data_qr)
qr_codes = True

if qr_codes and not contents:
# # # # 0.5s per image
Expand All @@ -84,6 +86,7 @@ def extract_qrcode(self, path):
decoded_text = qreader.detect_and_decode(image=image)
for d in decoded_text:
contents.append(d)
qr_codes = True
except ValueError as e:
self.logger.error(f'{e}: {self.obj.get_global_id()}')
return qr_codes, contents
Expand Down Expand Up @@ -122,7 +125,7 @@ def compute(self, message):
# TODO only if new ???
self.add_message_to_queue(obj=qr_code, queue='Item')

if is_qrcode:
if is_qrcode or contents:
tag = 'infoleak:automatic-detection="qrcode"'
self.add_message_to_queue(obj=self.obj, message=tag, queue='Tags')

Expand Down

0 comments on commit 4dbda59

Please sign in to comment.