Reject malformed channel QR links and document channel QR scanning

A name with invalid percent-encoding (e.g. name=%FF) made
Uri.queryParameters throw from the scanner's validator. The parser now
returns null for it, with a regression test.

Update the channels and additional-features guides for the renamed
"Scan a QR Code" option, the supported channel link format, and its
limits.
This commit is contained in:
zjs81 committed 2026-10-24 22:30:51 -07:00
1 parent b1e968e7bf
commit f58a76904a
4 files changed
+27 -8

No files matched your search

+12 -6
View File
@@ -76,19 +76,25 @@ An optional per-contact and per-channel text compression feature using the SMAZ
---
## Community QR Scanner
## Channel and Community QR Scanner
### How to Access
From Channels screen → "+" FAB → "Scan Community QR"
From Channels screen → "+" FAB → "Scan a QR Code"
### What the User Sees
A live QR scanner view with instruction text overlay.
### Key Interactions
- Scan a community QR code shared by another member
- On valid scan: confirmation dialog showing community name and ID
- Option to "Add public channel to device" on join
- If already a member: shows an "Already a member" dialog
- **Community QR code** (shared by another member):
- On valid scan: confirmation dialog showing community name and ID
- Option to "Add public channel to device" on join
- If already a member: shows an "Already a member" dialog
- **Channel QR code** (official MeshCore format, `meshcore://channel/add?name=…&secret=…`, as shared by the official app and sites like ipnt.uk):
- On valid scan: confirmation dialog asking to add the named channel to the radio
- The channel goes into the next free slot; if every slot is used, or the channel list is still syncing from the radio, a snackbar explains why and nothing is written
- If a channel with the same secret is already on the radio, a snackbar says so and scanning continues
- Names longer than the radio's 31-byte limit are shortened
- The optional `region_scope` parameter is not applied; set the channel's region manually afterwards
- Invalid QR: shows an orange error snackbar
---
+1 -1
View File
@@ -52,7 +52,7 @@ Tap the "+" FAB to open a dialog with six options:
2. **Join Private Channel** — Enter a name and a 32-hex PSK (non-hex characters like spaces and dashes are silently stripped, so pasted keys with formatting are accepted)
3. **Join Public Channel** — One tap; uses the well-known public PSK (only shown if no public channel exists)
4. **Join Hashtag Channel** — Enter a hashtag name; PSK is derived from the name. If communities exist, choose between regular hashtag (SHA-256) or community hashtag (HMAC)
5. **Scan Community QR** — Opens QR scanner to join a community
5. **Scan a QR Code** — Opens the QR scanner to join a community, or to add a channel from an official MeshCore channel QR code (`meshcore://channel/add?name=…&secret=…`, as shared by the official app and community sites)
6. **Create Community** — Enter a name; generates a random 32-byte secret; optionally adds a community public channel; shows QR code for sharing
Name limits count the `#` and any community prefix, so the name stored on the radio matches what you typed and others derive the same key. Adding a channel is blocked until the channel list has finished syncing from the radio (a snackbar says the channels are still loading), and the free slot is picked when you confirm, so an existing channel is never overwritten.
+8 -1
View File
@@ -28,7 +28,14 @@ ScannedChannel? parseChannelQr(String data) {
);
if (normalizedPath != 'channel/add') return null;
final params = uri.queryParameters;
// Decoding throws on malformed percent-encoding (e.g. `name=%FF`); the
// scanner calls this from its validator, so treat that as not a channel QR.
final Map<String, String> params;
try {
params = uri.queryParameters;
} on FormatException {
return null;
}
final name = (params['name'] ?? '').trim();
if (name.isEmpty) return null;
+6
View File
@@ -52,6 +52,12 @@ void main() {
isNull,
);
expect(parseChannelQr('https://ipnt.uk/channels'), isNull);
expect(
parseChannelQr(
'meshcore://channel/add?name=%FF&secret=8b3387e9c5cdea6ac9e5edbaa115cd72',
),
isNull,
);
expect(parseChannelQr('{"type":"meshcore_community"}'), isNull);
expect(parseChannelQr(''), isNull);
});