Skip to content

Redact API keys that wrap onto the next line - #2

Merged
tw4 merged 4 commits into
mainfrom
fix/wrapped-keys
Nov 11, 2026
Merged

tw4 merged 4 commits into
mainfrom
fix/wrapped-keys

Conversation

@tw4

@tw4 tw4 commented Nov 11, 2026

Copy link
Copy Markdown
Owner

Detection ran per OCR line, so a key that wrapped to the next line left its tail visible, and a key split into two short halves across lines was not detected at all.

  • Follow a key across a line break when the next line starts just below and further left with a random-looking piece (digit or inner capitals), or when the two halves together pass the API key check.
  • Unit tests for both cases and for an ordinary next line not being swallowed.
  • New fixture tests/fixtures/wrapped-key.png checked on the platform OCR engine (Windows.Media.Ocr / Vision / tesseract). With the fix disabled it fails on Windows: 5vXz7aBcQ3 is active stayed uncovered.

tw4 added 4 commits November 11, 2026 08:40
Detection ran per OCR line, so a key that wrapped left its tail visible on
the next line, and a key split into two short halves was not found at all.
Follow a key across the line break when the next line starts below and to
the left with a random-looking piece, or when both halves together look
like a key. Adds unit tests and a wrapped-key screenshot fixture that runs
on the platform OCR engine.
The temp image was named after the process id only, so two OCR runs in the
same process overwrote each other's image and one got the other's text.
Two platform OCR tests running in parallel hit this on Linux.
@tw4
tw4 merged commit af8d7c9 into main Nov 11, 2026
5 checks passed
@tw4
tw4 deleted the fix/wrapped-keys branch November 11, 2026 07:22
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