File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -52,15 +52,25 @@ def parse(
52
52
# If there is a UNA, take the following 6 characters
53
53
# unconditionally, strip them, and make control Characters()
54
54
# for further parsing
55
- idx_una = message .find ("UNA" )
55
+
56
+ # If it starts by UNA
57
+ una_pattern = "UNA"
58
+ if message .startswith (una_pattern ):
59
+ idx_una = 0
60
+ # Otherwise we look for UNA, so to avoid finding "lorem ipsum UNA lorem ipsum" we look for the segment separator following by UNA.
61
+ else :
62
+ una_pattern = "'UNA"
63
+ idx_una = message .find (una_pattern )
56
64
una_found = idx_una != - 1
57
65
58
66
if una_found :
59
- characters = Characters .from_str ("UNA" + message [idx_una + 3 : idx_una + 9 ])
67
+ idx_begin = idx_una + len (una_pattern )
68
+ idx_end = idx_begin + 6
69
+ characters = Characters .from_str (f"UNA{ message [idx_begin : idx_end ]} " )
60
70
61
71
# remove the UNA segment from the string,
62
72
# ignore everything before UNA because it should be the first segment if una_found.
63
- message = message [idx_una + 9 :].lstrip ("\r \n " )
73
+ message = message [idx_end :].lstrip ("\r \n " )
64
74
65
75
else :
66
76
# if no UNA header present, use default control characters
You can’t perform that action at this time.
0 commit comments