Repository navigation
fix(mqttRoots): accept roots and segments in any script #171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -203,7 +203,9 @@ for (const ed of events.editions ?? []) { | |
| /* ---------------------------------------------------------------- mqttRoots */ | ||
|
|
||
| // Clients save a root straight into the radio, so an entry must pass the firmware's own root rules: | ||
| // 31 bytes, printable ASCII, no wildcards, no empty segment, not ending in the /2 version level. | ||
| // 31 bytes, no whitespace, control or invisible characters, no wildcards, no empty segment, not | ||
| // ending in the /2 version level. Letters in any script are fine: the firmware stores the root as | ||
| // UTF-8, and communities write theirs in their own letters (msh/EU_868/NO/Østlandet). | ||
| const ISO_SUBDIVISION = /^[A-Z]{2}-[A-Z0-9]{1,3}$/; | ||
| const roots = readJson("data/mqttRoots.json"); | ||
| const seenRoots = new Set<string>(); | ||
|
|
@@ -214,7 +216,8 @@ for (const e of roots.entries ?? []) { | |
| continue; | ||
| } | ||
| if (Buffer.byteLength(e.root) > 31) fail(`${where}: longer than 31 bytes`); | ||
| if (!/^[\x21-\x7e]+$/.test(e.root)) fail(`${where}: not printable ASCII`); | ||
| if (/[\s\p{Cc}\p{Cf}]/u.test(e.root)) | ||
| fail(`${where}: contains whitespace, a control or an invisible character`); | ||
| if (/[+#]/.test(e.root)) fail(`${where}: contains a wildcard`); | ||
| if (e.root.endsWith("/") || e.root.includes("//")) | ||
| fail(`${where}: empty segment`); | ||
|
|
@@ -269,7 +272,7 @@ for (const [country, names] of Object.entries<Record<string, string>>( | |
| fail( | ||
| `mqttRoots subdivisionSegments ${country}: "${name}" must be lowercase`, | ||
| ); | ||
| if (!/^[A-Za-z0-9_-]+$/.test(segment)) | ||
| if (!/^[\p{L}\p{N}_-]+$/u.test(segment)) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Allow marks needed by subdivision names. This expression rejects
|
||
| fail( | ||
| `mqttRoots subdivisionSegments ${country}: bad segment "${segment}"`, | ||
| ); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reject invisible characters outside
Cf.A root such as
msh/US/CA\u034Fpasses this check, although U+034F is invisible. It looks likemsh/US/CAbut identifies a different MQTT topic. Reject\p{Default_Ignorable_Code_Point}as well. (unicode.org)