feat: $sanitize (spec 013) and $exceptionHandler (spec 014)#29
Merged
feat: $sanitize (spec 013) and $exceptionHandler (spec 014)#29
Conversation
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
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.
Summary
Ships two AngularJS-parity services and the planning docs for a follow-up.
Spec 013 —
$sanitize(HTML sanitization):ngSanitizemodule (separate./sanitizesubpath, never on coreng) — apps that don't render untrusted HTML pay no cost.createSanitize/sanitizefactory +$SanitizeProviderDI shim withaddValidElements/addValidAttrs/enableSvg/uriPatternsetters.htmlParser; tag + attribute + URL-protocol allow-lists default to AngularJS 1.8.x.$sce.getTrustedHtmlautomatically delegates plain strings through$sanitizewhenngSanitizeis loaded — lazy$injector.has('$sanitize')lookup, no hard dep, no decoration.cve-regressions.test.tscovers historicalngSanitizeadvisories (CVE-2020-7676, CVE-2018-12116, CVE-2014-3506).Spec 014 —
$exceptionHandler(centralized exception routing):ngmodule registers$exceptionHandler(default =console.error); apps override viamodule.factoryormodule.decorator.console.errorswallowing sites insrc/core/scope.ts(watchFn,watchListener,$evalAsync,$applyAsync,$$postDigest,eventListener) plus the digest TTL throw all route through a recursion-guardedinvokeExceptionHandlerhelper.$interpolaterender-time errors caught and routed via$exceptionHandlerwith cause'$interpolate'; failed expression slots render as'';allOrNothingandoneTimeshort-circuits preserved.EXCEPTION_HANDLER_CAUSESvocabulary frozen and exported as anExceptionHandlerCauseunion.Scope.create({ exceptionHandler })andcreateInterpolate({ exceptionHandler })accept the option for ESM consumers.Spec 015 —
$provide(planning only):config(['$provide', \$p => \$p.factory(...)])gap surfaced by spec 014's skipped DI test (one of the six skipped tests in this PR waits on\$provide).Test plan
pnpm lint— cleanpnpm format:check— cleanpnpm typecheck— cleanpnpm test— 1603 passing + 6 skipped across 45 files (one skipped test waits on spec 015 /\$provide)pnpm build— succeeds; new./sanitizeand./exception-handlersubpaths emit.mjs,.cjs, and.d.tsStatus: Completed; roadmap items tickedDocs
CLAUDE.mdgains./sanitizeand./exception-handlerModules rows, new Non-obvious-invariants bullets (opt-inngSanitize; digest "log and continue" through\$exceptionHandler), and two new "Where to look when…" entries.src/sanitize/README.mdandsrc/exception-handler/README.mddocument override patterns, allow-list extension recipes, the recursion-guard contract, and CVE-regression coverage.package.jsonexports,rollup.config.mjsbuild entries, and path aliases (tsconfig.json,vitest.config.ts,rollup.config.mjs) extended for both new subpaths.context/product/roadmap.mdticksSecurity (\$sanitize)andException Handling (\$exceptionHandler); adds a Phase 1 DI follow-up entry for spec 015's\$provide.🤖 Generated with Claude Code