Skip to content

Commit

Permalink
parsing: fix incorrect parsing of msgNo
Browse files Browse the repository at this point in the history
msgNo should accept alphanumeric characters

fix #36
  • Loading branch information
rossengeorgiev committed Jan 20, 2018
1 parent acb4c66 commit 94b89a6
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions aprslib/parsing/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

1 comment on commit 94b89a6

@stroobandt
Copy link

@stroobandt stroobandt commented on 94b89a6 Oct 5, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. This important bug fix has still not made it on PyPI, where the provided aprslib version number is 0.6.46.
  2. I know, the APRS specification states message IDs ought to be alphanumerical, but in practice I am seeing now any group of five printable ASCII characters as a message ID behind the {.

Could you please fix this? I am trying to develop an application using your library, but unfortunately I need to jump through hoops to circumvent these special message IDs. Thanks & 73 de ON4AA

Please sign in to comment.