Repository navigation
Read a notification's code whole, and only when it starts by its keyword - #18556
Merged
Merged
Conversation
Codes were matched inside a slice cut out around each keyword, and the slice's edges counted as word boundaries, so a number crossing a window's start was offered as its tail (23456) and one crossing its end was cut short (48291). Matching over the whole text reads each code to its real edges; keeping only matches whose code starts inside a window stops a number that merely grazes a window's start from being pulled in and outranking the real code. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
[Medium impact] The PR appears safe to merge. Summary
Reviews (1) · Last reviewed commit: "Read a notification's code whole, and on..." · Reviewed by Greptile |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A notification with the summary
123456and the bodyYour verification code is 123456offered two buttons, Copy 123456 and Copy 23456, and the second copied the code with its first digit gone.AB12CD34overUse the sign-in code AB12CD34offered Copy B12CD34 the same way, and a code that runs past the end of its keyword's window was copied short: 48291 from 48291375.Detect.jslooks for a code in a window around each code keyword, 24 characters before and 72 after.codes()cut each window out withslice()and matched the code shapes inside the piece, and the shapes' word-boundary checks treated the cut's edges as word edges. A number crossing the window's start was read from the cut onward, and one crossing its end up to the cut.harvest()now matches over the whole text, so each shape's boundaries read the real characters on both sides and a code is taken whole. A match counts only when the code itself starts inside a window. A match that merely reaches into a window is not enough:12345678followed by twenty dots andcode A9F3K2would then offer 12345678, and since a numeric code wins over a letter-and-digit one, it would hide the real A9F3K2. The file's own rule is that a false positive is worse than a miss, so a number that only grazes a window's start is left out. Order, de-duplication, the year filter, the cap, the Do Not Disturb bypass on the first code and the redaction of stored rows are unchanged.The new case in
test/shell.d/notifications/logic.cjschecks all four texts above and fails onquattro, which offers123456 23456,B12CD34 AB12CD34,48291and5678. With this change it offers123456,AB12CD34,48291375andA9F3K2. On a worker built from the Omarchy ISO with its shell serving this branch, each was sent withnotify-sendand its buttons pressed withomarchy-shell notifications invokeAction. Onquattrothe reported card's buttons copied 123456 and 23456; with this change it has one button, which copies 123456, and the long-code card copies 48291375 instead of 48291.Sign inover the same body still offers one button that copies 123456.Not changed here:
isProductNamestill reads only the 20 characters beforeCode, and codes and links are still read from the first 32K characters only.Found by Prime's QA pass; matching over the whole text is their approach, narrowed here to codes that start inside a window. The other detector bug, a number the text says is not a code, is a separate fix.
Reviewed by Codex Medium, which found no defect and timed the scan on 32K hostile input well inside the existing budget; its independence is not guaranteed. A second panel reviewer, muse-wonder via pi, did not answer.
🤖 Generated by Opus 5.5 in Claude Code. Reviewed by Codex Medium.