Repository navigation
Conversation
…ge work budget; aria-labelledby target reads charged to the visits #1462 Signed-off-by: Nik Cubrilovic <[email protected]>
…ds counted; default-budget shapes also at a quarter size #1462 Signed-off-by: Nik Cubrilovic <[email protected]>
…ounted unread, not skipped as having no destination or cue #1462 Signed-off-by: Nik Cubrilovic <[email protected]>
…p 4,096), distinct aria-labelledby targets metered before reading, edges pinned, test hook off in production #1462 Signed-off-by: Nik Cubrilovic <[email protected]>
…269, pe, ghe, braille blank) and reads digit swaps inside words #1410 Signed-off-by: Nik Cubrilovic <[email protected]>
…nded by length and page budget, attribute windows folded, capital lunate sigma #1410 Signed-off-by: Nik Cubrilovic <[email protected]>
nc9
force-pushed
the
fix/confusables-1410
branch
from
November 2, 2026 09:56
1ac774f to
3a20f69
Compare
…aracters outside the page pool; exhaustion keeps the plain reading; boundaries pinned #1410 Signed-off-by: Nik Cubrilovic <[email protected]>
nc9
added a commit
that referenced
this pull request
Nov 2, 2026
…guarantee, the pool limit and the measured cost #1541 Signed-off-by: Nik Cubrilovic <[email protected]>
4 tasks done
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.
Fixes #1410, refs #784.
Reproduced on main (v0.0.159) before the change. A
GoogleorMicrosoftsign-in link to an off-brand host,detectBrandImpersonation: not found on main withϲontinue with Google(U+03F2),sɩgn ɩn wɩth Google(U+0269),sigп іп with Google(Cyrillicп),Sign in with Micгosoft(Cyrillicг),Si⠀gn in with Goo⠀gle(braille blank U+2800 spliced in), andS1gn 1n w1th G00gle,L0g1n w1th Google,C0nt1nue w1th Google,Sign 1n with Google. The three tests for them fail on main; the ordinary-number and other-language tests pass there (they are the baseline).Change (new
packages/rules/src/integrity/confusables.ts;controls.tsloses the table and its two helper constants and gains an import and one changed line inscanControls, so it rebases cleanly under #1462):confusables.tswithϲandς(NFKC turns U+03F2 into the final sigma U+03C2, so both are mapped),ɩ,п,гadded; U+2800 joins the invisible characters.digitForms(text): in a word ([\p{L}\p{N}]+) that has a letter and one of0 1 3 5,0iso,3ise,5iss, and1isiorl, whichever makes a word of the cue (the word list is derived from the auth phrases and the brand lexicons and action cues):s1gnissign,g00g1eisgoogle,1og1nislogin; a cue word of the token's length is compared letter by letter, each1standing foriorl; no cue word either way reads withi. A number on its own (1995,10,5) and a word with only other digits (24h) are untouched. Applied to each label form inscanControls; the page-text haystack is unchanged.Not firing (tests): prices, years, versions,
H1,24h,Sign 5 timeson a page; Russian, Spanish and German sign-in labels (Войти через Google,Iniciar sesión con Google,Mit Google anmelden, ...), to an off-brand host and to Google itself.Rebased on #1538 (9cb20e5, the work budget): this branch now carries #1538's commits below its own; the CHANGELOG and the rule page paragraph conflicts are resolved.
Review round (the first version folded only the folded reading and the fold was unbounded):
digitFormsreturns the text as written first and the fold when it differs, so a cue with a digit in it matches:Office365 login,Office365 LoginandMicrosoft Office365 Loginto an off-brand host are Microsoft (the first version readoffice365asofficee6sand lost them).attributeLimits.fold, in the same object as fix(rules): integrity controls: attributes read once and charged to a work budget; aria-labelledby target reads charged to the visits #1462 #1538's budgets) across labels and attributes, and a control whose label or attribute was not folded in full is counted incontrolsUnread. A single 10 MiB text node of1a1b1c1dtokens, and a page of such links, no longer skipbrand-impersonationandfake-auth-overlayat the default budget (on the first version, one 10 MiB link took 4,012 ms against 195 ms on base and both rules were skipped; 20,000 links of 360 characters: 4.8 s then, 0.55 to 0.78 s now with the budget off).1-heavy word: a cue word of the token's length is compared letter by letter with each1standing foriorl(about 5 times faster).aria-labelortitlefillers of 16,000 characters of1a1b1c1dspent the 2,000,000-character pool, and a swapped cue in a text or an attribute after them was missed; the plain reading was never affected): the first 300 characters of a control's attributes and the first 300 of its text fold outside the pool, and the pool is charged only for what is past them (the whole text when both cover it, else only the control's own allowance folds). A short swapped-digit label folds whatever the pool holds, before or after the fillers; the label as written is always read; a control not folded in full is counted unread. Cost: the allowance is bounded by page bytes (a 12.5 MB page of 20,000 links with 300 characters of digit-heavy attribute and text each ran 1.1 s with the budget off); a page of 60,000 such controls, 37 MB, is past the 10 MiB cap.c: it is mapped before NFKC (which would make it a sigma); U+03F2 is covered by the NFKC path and tested throughreadable.iand anl(signinwithg00g1e) is read withiand is not a cue, and page text is not digit-folded, only the text and attributes of controls.Mutants (each separately, restored from a clean copy after each): the allowance round adds the exact-fit comparison, the allowance consumption, its size (0, 299, 301), the plain reading dropped in the exhausted text and attribute paths, the partial head fold, the pool charge and both cut counts, each failing a test; this round's earlier set (the 23-mutant set of the first version targeted code this round rewrote, so it was rebuilt): the as-written reading dropped, the fold applied without the guard (equivalent),
1read only asior only asl, the fallback asl,5not folded, the digit guard without0, the label bound at 15,999 and 16,001, the cut not counted, the budget check, its cut count and its charge removed, a label folded past 16,000, the attribute fold charge removed or always on, an exhausted attribute not counted, the lunate sigma pre-fold removed or only one of its two code points, and the budget unbounded each fail a test. Equivalent survivors: the early return for a token without a1, and U+03F2 in the pre-fold (NFKC and the table already map it).Docs: the label normalisation sentence of
docs/rules/integrity/brand-impersonation.mdx; CHANGELOG entry.Tests:
packages/rules/tests/confusables-1410.test.ts(18) andintegrity-fold-budget-1410.test.ts(17: bounds by counts, the allowance and the pool, and the rules at the default budget, a quarter size always and full size when the machine is quiet). Passing, each file on its own: integrity, integrity-text-boundary, integrity-budget-1424, integrity-budget-784, integrity-bounds-1423, integrity-budget-1495, integrity-unread-once-1491, integrity-evasions-784 and integrity-adversarial-784 (one linearity-ratio test failed once under a load average of 17 and passed 3 of 3 alone); tsgo; docsmake validate; the changelog guard.Skill: no change needed.
nik