fix(audio): validate settings and finite duration in shouldSaveDiscardedRecording - #1806
fix(audio): validate settings and finite duration in shouldSaveDiscardedRecording#1806hsusul wants to merge 1 commit into
Conversation
|
Thanks for this one, @hsusul — closing along with #1805 after tracing where both inputs come from.
The direction of the guard matters here too: this feature exists to preserve discarded audio (#964/#907 — the min-duration check only filters accidental sub-second Escape taps). If an unknown duration ever did appear, silently declining to save would lose exactly the audio the feature protects, so failing open is the safer default for this one. Really appreciate the attention to the audio pipeline — thank you! |
Fixes #1805
Problem
In
src/helpers/discardedRecording.js:shouldSaveDiscardedRecordingcheckeddurationSeconds >= MIN_DISCARDED_DURATION_SECONDS, which allowedInfinityto improperly evaluate totrue.settingswas passed as a non-object primitive, it wasn't validated upfront.Solution
if (!settings || typeof settings !== "object") return false;upfront.Number.isFinite(durationSeconds) && durationSeconds >= MIN_DISCARDED_DURATION_SECONDS.test/helpers/discardedRecording.test.js.Verification
node --test test/helpers/discardedRecording.test.js(passes, 5/5 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)