fix #65 missing padding on seturl

This commit is contained in:
Kevin Hester committed 2021-03-10 11:01:07 +08:00
1 parent 7c6744704d
commit af94824bca
2 files changed
+11 -2

No files matched your search

+1 -1
View File
@@ -58,7 +58,7 @@
"request": "launch",
"module": "meshtastic",
"justMyCode": true,
"args": ["--seturl", "https://www.meshtastic.org/c/#GAMiENTxuzogKQdZ8Lz_q89Oab8qB0RlZmF1bHQ="
"args": ["--seturl", "https://www.meshtastic.org/d/#CgIYAw"
]
},
{
+10 -1
View File
@@ -391,7 +391,16 @@ class MeshInterface:
# URLs are of the form https://www.meshtastic.org/d/#{base64_channel_set}
# Split on '/#' to find the base64 encoded channel settings
splitURL = url.split("/#")
decodedURL = base64.urlsafe_b64decode(splitURL[-1])
b64 = splitURL[-1]
# We normally strip padding to make for a shorter URL, but the python parser doesn't like
# that. So add back any missing padding
# per https://stackoverflow.com/a/9807138
missing_padding = len(b64) % 4
if missing_padding:
b64 += '='* (4 - missing_padding)
decodedURL = base64.urlsafe_b64decode(b64)
channelSet = apponly_pb2.ChannelSet()
channelSet.ParseFromString(decodedURL)