Skip to content

fix(dictionary): coerce string boolean values in applyAutoLearnSetting - #1922

Open
hsusul wants to merge 1 commit into
OpenWhispr:mainfrom
hsusul:fix/1921-auto-learn-setting-coercion
Open

fix(dictionary): coerce string boolean values in applyAutoLearnSetting#1922
hsusul wants to merge 1 commit into
OpenWhispr:mainfrom
hsusul:fix/1921-auto-learn-setting-coercion

Conversation

@hsusul

@hsusul hsusul commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Fixes #1921

Problem

In src/helpers/autoLearnSetting.js:

  • applyAutoLearnSetting(current, incoming) directly used !!incoming.
  • When passed serialized string boolean values (such as "false", "0", or "off") from IPC, query parameters, or stringified storage, Boolean("false") evaluated to true, erroneously turning on auto-learn.

Solution

  • Introduced a string-aware boolean coercion helper coerceToBoolean that properly interprets falsey strings ("false", "0", "off", "no", "") and truthy strings ("true", "1", "on", "yes").
  • Applied proper coercion to both incoming and current arguments.
  • Added unit tests in test/helpers/autoLearnSetting.test.js.

Verification

  • node --test test/helpers/autoLearnSetting.test.js (passes, 6/6 tests)
  • npm run typecheck (passes, 0 errors)
  • npm run lint (passes, 0 errors)
  • npm run i18n:check (passes)
  • npm run build:renderer (passes)
  • git diff --check (clean)

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.

applyAutoLearnSetting misinterprets "false" and "0" string values as true

1 participant