{"record":{"id":"45db86cac830863f","repo":"angular/angular","slug":"ng0905","errorCode":"NG0905","errorMessage":"unsafe value used in a script context","messagePattern":"unsafe value used in a script context","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"packages/core/src/sanitization/sanitization.ts","lineNumber":172,"sourceCode":" * bypassSanitizationTrustScript}.\n *\n * @param unsafeScript untrusted `script`, typically from the user.\n * @returns `url` string which is safe to bind to the `<script>` element such as `<img src>`,\n * because only trusted `scripts` have been allowed to pass.\n *\n * @codeGenApi\n */\nexport function ɵɵsanitizeScript(unsafeScript: any): TrustedScript | string {\n  const sanitizer = getSanitizer();\n  if (sanitizer) {\n    return trustedScriptFromStringBypass(\n      sanitizer.sanitize(SecurityContext.SCRIPT, unsafeScript) || '',\n    );\n  }\n  if (allowSanitizationBypassAndThrow(unsafeScript, BypassType.Script)) {\n    return trustedScriptFromStringBypass(unwrapSafeValue(unsafeScript));\n  }\n  throw new RuntimeError(\n    RuntimeErrorCode.UNSAFE_VALUE_IN_SCRIPT,\n    ngDevMode && 'unsafe value used in a script context',\n  );\n}\n\n/**\n * A template tag function for promoting the associated constant literal to a\n * TrustedHTML. Interpolation is explicitly not allowed.\n *\n * @param html constant template literal containing trusted HTML.\n * @returns TrustedHTML wrapping `html`.\n *\n * @security This is a security-sensitive function and should only be used to\n * convert constant values of attributes and properties found in\n * application-provided Angular templates to TrustedHTML.\n *\n * @codeGenApi\n */","sourceCodeStart":154,"sourceCodeEnd":190,"githubUrl":"https://github.com/angular/angular/blob/51cb07e98081ab7e4e84a9e0949266a8e19cca84/packages/core/src/sanitization/sanitization.ts#L154-L190","documentation":"Error \"unsafe value used in a script context\" thrown in angular/angular.","triggerScenarios":"Thrown at packages/core/src/sanitization/sanitization.ts:172 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Remove the unsafe script value or use an approved sanitization bypass."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"51cb07e98081ab7e4e84a9e0949266a8e19cca84","analyzedAt":"2026-08-22T07:04:54.531Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}