Skip to content

Sanitize search queries and ensure config file exists#2

Open
hanfoo wants to merge 2 commits intoraywill:mainfrom
hanfoo:main
Open

Sanitize search queries and ensure config file exists#2
hanfoo wants to merge 2 commits intoraywill:mainfrom
hanfoo:main

Conversation

@hanfoo
Copy link

@hanfoo hanfoo commented Mar 15, 2026

Motivation

  • Prevent unescaped user input from breaking or injecting into search regular expressions and make configuration handling more robust when the config file is missing or corrupted.

Description

  • Add escapeRegExp and apply it in processContent and formatResults to safely escape the search query used in regexes.
  • Add ensureConfigFile to create a default config at configName, ensure parent directories exist, and recover from corrupted JSON by overwriting with defaults.
  • Refactor initMenu to use ensureConfigFile and remove the previous fragile file-read/try-catch flow while preserving upgrade logic for older config shapes.
  • Guard fs.watch(configName) on app ready with fs.existsSync(configName) so file-watching is only set when the config file exists.

hanfoo added 2 commits March 15, 2026 23:09
Sanitize search queries and ensure config file exists; refactor menu init
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.

1 participant