From 94b89a6da47a322129484efcaf1e82f6a9932891 Mon Sep 17 00:00:00 2001 From: Rossen Georgiev Date: Sat, 20 Jan 2018 14:55:23 +0000 Subject: [PATCH] parsing: fix incorrect parsing of msgNo msgNo should accept alphanumeric characters fix #36 --- aprslib/parsing/message.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/aprslib/parsing/message.py b/aprslib/parsing/message.py index e9c1ee6..3995629 100644 --- a/aprslib/parsing/message.py +++ b/aprslib/parsing/message.py @@ -73,27 +73,24 @@ def parse_message(body): logger.debug("Packet is just a regular message") parsed.update({'format': 'message'}) - match = re.findall(r"^(ack|rej)([0-9]{1,5})$", body) + match = re.search(r"^(ack|rej)([A-Za-z0-9]{1,5})$", body) if match: - response, number = match[0] - parsed.update({ - 'response': response, - 'msgNo': number + 'response': match.group(1), + 'msgNo': match.group(2), }) else: body = body[0:70] - match = re.findall(r"([0-9]{1,5})$", body) + match = re.search(r"{([A-Za-z0-9]{1,5})$", body) if match: - msgid = match[0] - body = body[:len(body) - 1 - len(msgid)] + msgNo = match.group(1) + body = body[:len(body) - 1 - len(msgNo)] - parsed.update({'msgNo': int(msgid)}) + parsed.update({'msgNo': msgNo}) parsed.update({'message_text': body.strip(' ')}) break return ('', parsed) -