Skip to content

Commit

Permalink
Updating URL regex for QR scanner (#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexk307 authored Jun 28, 2023
1 parent c6f5476 commit ba8fc81
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/python/strelka/scanners/scan_qr.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@

from strelka import strelka

# Regex to match URL
# NOTE: this is overly simplified but will be validated elsewhere
URL_REGEX = r'^[a-zA-Z]{3,10}:\/\/.*'


class ScanQr(strelka.Scanner):
"""
Collects QR code metadata from image files.
"""
def scan(self, data, file, options, expire_at):
try:
URL_REGEX = '^((https?|ftp|smtp):\/\/)?(www.)?[a-z0-9]+\.[a-z]+(\/[a-zA-Z0-9#]+\/?)*'
barcodes = decode(Image.open(io.BytesIO(data)))

try:
Expand All @@ -28,9 +31,6 @@ def scan(self, data, file, options, expire_at):
# Type: Mobile
elif any(qtype in self.event['data'] for qtype in ['tel:', 'sms:']):
self.event['type'] = 'mobile'
# Type: App
elif any(qtype in self.event['data'] for qtype in ['itunes.apple.com', 'market://']):
self.event['type'] = 'app'
# Type: Geo
elif 'geo:' in self.event['data']:
self.event['type'] = 'geo'
Expand Down

0 comments on commit ba8fc81

Please sign in to comment.