MCPcopy Create free account
hub / github.com/cure53/DOMPurify / _applyTrustedTypesToAttribute

Function _applyTrustedTypesToAttribute

src/purify.ts:2242–2270  ·  view source on GitHub ↗
(
    lcTag: string,
    lcName: string,
    namespaceURI: string | null,
    value: string
  )

Source from the content-addressed store, hash-verified

2240 * @return the value, wrapped when Trusted Types demand it
2241 */
2242 const _applyTrustedTypesToAttribute = function (
2243 lcTag: string,
2244 lcName: string,
2245 namespaceURI: string | null,
2246 value: string
2247 ): string {
2248 if (
2249 trustedTypesPolicy &&
2250 typeof trustedTypes === 'object' &&
2251 typeof trustedTypes.getAttributeType === 'function' &&
2252 !namespaceURI
2253 ) {
2254 switch (trustedTypes.getAttributeType(lcTag, lcName)) {
2255 case 'TrustedHTML': {
2256 return _createTrustedHTML(value);
2257 }
2258
2259 case 'TrustedScriptURL': {
2260 return _createTrustedScriptURL(value);
2261 }
2262
2263 default: {
2264 break;
2265 }
2266 }
2267 }
2268
2269 return value;
2270 };
2271
2272 /**
2273 * Write a modified attribute value back onto the element. On

Callers 1

_sanitizeAttributesFunction · 0.85

Calls 2

_createTrustedHTMLFunction · 0.85
_createTrustedScriptURLFunction · 0.85

Tested by

no test coverage detected