Skip to content

fix(color): model files may not import into Companion if widget option string contains certain characters - #7831

Merged
pfeerick merged 2 commits into
mainfrom
philmoz/fix-widget-option-yaml
Sep 29, 2026
Merged

pfeerick merged 2 commits into
mainfrom
philmoz/fix-widget-option-yaml

Conversation

@philmoz

@philmoz philmoz commented Sep 26, 2026

Copy link
Copy Markdown
Collaborator

Ensure widget option string values are enclosed in quotes and special characters are encoded.

Fixes: #7829

@philmoz philmoz added this to the 3.0 milestone Sep 26, 2026
@philmoz philmoz added color Related generally to color LCD radios bug/regression ↩️ A new version of EdgeTX broke something backport/2.12 To be backported to a 2.12 release also. labels Sep 26, 2026
@pfeerick pfeerick modified the milestones: 3.0, 2.12.5 Sep 27, 2026
…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>
@pfeerick

pfeerick commented Sep 28, 2026 •

Copy link
Copy Markdown
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
pfeerick merged commit 0b2e470 into main Sep 29, 2026
54 checks passed
@pfeerick
pfeerick deleted the philmoz/fix-widget-option-yaml branch September 29, 2026 01:23
@pfeerick pfeerick mentioned this pull request Oct 2, 2026
37 of 38 tasks
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport/2.12 To be backported to a 2.12 release also. bug/regression ↩️ A new version of EdgeTX broke something color Related generally to color LCD radios

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Text Widget with a trailing colon

2 participants