Skip to content

Fix utf8 bom parsing (#2510) - #2512

Merged
AucaCoyan merged 3 commits into
espanso:devfrom
gcailly:fix-utf8-bom-parsing-2510
Oct 6, 2025
Merged

AucaCoyan merged 3 commits into
espanso:devfrom
gcailly:fix-utf8-bom-parsing-2510

Conversation

@gcailly

@gcailly gcailly commented Oct 6, 2025

Copy link
Copy Markdown
Contributor

This PR fixes issue #2510 where YAML configuration and match files created with Windows editors (like Notepad) that add a UTF-8 BOM were not parsed correctly by espanso.

Changes :

  • Added UTF-8 BOM removal (\u{FEFF}) in YAMLMatchGroup::parse_from_str() and YAMLConfig::parse_from_str().
  • Simplified the parse_from_file() methods to rely on parse_from_str() for consistent BOM handling.

Fixes #2510

…panso#2483)

When running commands like `espanso service --help` or `espanso package --help`,
the CLI was displaying the main application help instead of the specific
subcommand help.

This was caused by using `clap_instance.print_help()` which always prints
the root command help, instead of using `err.exit()` which properly handles
contextual help for subcommands.

Fix: Use `err.exit()` to let Clap handle contextual help display.

Fixes espanso#2483
Windows editors like Notepad add a UTF-8 Byte Order Mark (BOM) at the
beginning of files. This caused Espanso to either ignore these files
or fail to parse them correctly.

This fix strips the BOM character (\u{FEFF}) from YAML content before
parsing, allowing proper handling of files created with Windows editors.

Fixes espanso#2510
@gcailly
gcailly requested a review from AucaCoyan as a code owner October 6, 2025 07:46
@AucaCoyan

Copy link
Copy Markdown
Collaborator

Thanks! never used espanso with notepad 🤣

@AucaCoyan
AucaCoyan merged commit a720df4 into espanso:dev Oct 6, 2025
sboldt1978 pushed a commit to sboldt1978/espanso that referenced this pull request Feb 11, 2026
* Fix subcommand help displaying main help instead of specific help (espanso#2483)

When running commands like `espanso service --help` or `espanso package --help`,
the CLI was displaying the main application help instead of the specific
subcommand help.

This was caused by using `clap_instance.print_help()` which always prints
the root command help, instead of using `err.exit()` which properly handles
contextual help for subcommands.

Fix: Use `err.exit()` to let Clap handle contextual help display.

Fixes espanso#2483

* Fix parsing of YAML files with UTF-8 BOM

Windows editors like Notepad add a UTF-8 Byte Order Mark (BOM) at the
beginning of files. This caused Espanso to either ignore these files
or fail to parse them correctly.

This fix strips the BOM character (\u{FEFF}) from YAML content before
parsing, allowing proper handling of files created with Windows editors.

Fixes espanso#2510
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

If there is a BOM in the configuration file, the file is ignored

2 participants