fix(color): model files may not import into Companion if widget option string contains certain characters - #7831
Merged
Merged
Conversation
…og labels Extends the widget option fix to the other custom writers that emitted user-controlled strings raw: - w_widget_name: Lua widget names - w_keyShortcut / w_qmFavorite: "APP,<tool name>" is now written as a single quoted scalar (non-APP shortcuts stay unquoted) - _write_analog_name: stick / pot custom labels were wrapped in quotes but '"' and '\' were not escaped Names containing ': ', ' #', a leading quote / bracket, etc. produced YAML that Companion could not load, and '"' or '\' were mangled when read back by the radio. Adds gtests covering the emitted scalar and radio round-trip for each writer, and that legacy unquoted files still load. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
|
There were a couple more low hanging fruit writers that could have scrambled things for companion also - Lua widget names, key-shortcut / Quick Menu favourite tool names, and stick/pot names - just another reminder to never blindly trust any user configurable input to be valid! |
pfeerick
added a commit
that referenced
this pull request
Oct 2, 2026
Not an upstream cherry-pick. Partial port of ed71a38 (#7562, "feat(firmware): add 'user data' section to model yaml for Lua scripts", milestone 3.0, main-only), taking only its yaml_tree_walker.{h,cpp} and yaml_parser.cpp hunks, unchanged: - yaml_output_string() is no longer static, and is declared in yaml_tree_walker.h with a new 'exact' flag (default false, the old behaviour; true writes max_len bytes even past a NUL, for std::string contents). - '\' is now written as \x5C, like '"' already is as \x22. 2.12's parser already decodes \xNN inside quoted strings, but otherwise drops a lone backslash, so a literal '\' didn't survive a round trip. - The radio parser now accepts lowercase hex in \xNN, and \b \t \n \f \r, inside quoted strings. That's what Companion's yaml-cpp writes. Without it, a lowercase escape stops the parser and the rest of the file isn't loaded. This is a prerequisite for the next commit (#7831), which writes widget names, widget option strings and analog labels with yaml_output_string(). That function escapes bytes >= 0x80 (e.g. UTF-8 text) as \xNN. Companion reads those back as separate characters and may save C1 code points as lowercase escapes. The parser change makes 2.12 read such files completely, as main does. The garbled UTF-8 text in Companion itself also happens on main and isn't addressed here. The rest of #7562 (the Lua user data feature) is not included. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
pfeerick
pushed a commit
that referenced
this pull request
Oct 2, 2026
…option string, switch name, contains certain characters (#7831) Co-authored-by: Peter Feerick <5500713+pfeerick@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 0b2e470) Adapted for 2.12 (depends on the previous commit, which exports yaml_output_string() as on main): - yaml_datastructs_funcs.cpp: the widget name, widget option string and analog label hunks applied as upstream. The w_keyShortcut() / w_qmFavorite() hunks are dropped: on 2.12 key shortcuts and quick menu favourites are a plain QMPage enum with no app/tool name, so there are no user strings to quote and those functions don't exist. - tests/yaml_strings.cpp: removed the KeyShortcutToolName, FavoriteToolName and NonAppShortcutsUnquoted tests, the shortcut part of ReadsLegacyUnquotedValues, and the tool-name resets in resetStorage(), which all need main's key shortcut API. The widget option, screen and topbar widget name, analog label and legacy-model tests are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ensure widget option string values are enclosed in quotes and special characters are encoded.
Fixes: #7829