dompurify 3.0.1 → 3.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  DOMPurify is a DOM-only, super-fast, uber-tolerant XSS sanitizer for HTML, MathML and SVG.
8
8
 
9
- It's also very simple to use and get started with. DOMPurify was [started in February 2014](https://github.com/cure53/DOMPurify/commit/a630922616927373485e0e787ab19e73e3691b2b) and, meanwhile, has reached version 3.0.1.
9
+ It's also very simple to use and get started with. DOMPurify was [started in February 2014](https://github.com/cure53/DOMPurify/commit/a630922616927373485e0e787ab19e73e3691b2b) and, meanwhile, has reached version **v3.0.3**.
10
10
 
11
11
  DOMPurify is written in JavaScript and works in all modern browsers (Safari (10+), Opera (15+), Edge, Firefox and Chrome - as well as almost anything else using Blink, Gecko or WebKit). It doesn't break on MSIE or other legacy browsers. It simply does nothing.
12
12
 
@@ -271,13 +271,13 @@ var clean = DOMPurify.sanitize(dirty, {ADD_URI_SAFE_ATTR: ['my-attr']});
271
271
  * Control permitted attribute values
272
272
  */
273
273
  // allow external protocol handlers in URL attributes (default is false, be careful, XSS risk)
274
- // by default only http, https, ftp, ftps, tel, mailto, callto, cid and xmpp are allowed.
274
+ // by default only http, https, ftp, ftps, tel, mailto, callto, sms, cid and xmpp are allowed.
275
275
  var clean = DOMPurify.sanitize(dirty, {ALLOW_UNKNOWN_PROTOCOLS: true});
276
276
 
277
277
  // allow specific protocols handlers in URL attributes via regex (default is false, be careful, XSS risk)
278
- // by default only http, https, ftp, ftps, tel, mailto, callto, cid and xmpp are allowed.
279
- // Default RegExp: /^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i;
280
- var clean = DOMPurify.sanitize(dirty, {ALLOWED_URI_REGEXP: /^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp|xxx):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i;});
278
+ // by default only http, https, ftp, ftps, tel, mailto, callto, sms, cid and xmpp are allowed.
279
+ // Default RegExp: /^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i;
280
+ var clean = DOMPurify.sanitize(dirty, {ALLOWED_URI_REGEXP: /^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|xxx):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i;});
281
281
 
282
282
  /**
283
283
  * Influence the return-type
@@ -291,6 +291,15 @@ var clean = DOMPurify.sanitize(dirty, {RETURN_DOM_FRAGMENT: true});
291
291
  // use the RETURN_TRUSTED_TYPE flag to turn on Trusted Types support if available
292
292
  var clean = DOMPurify.sanitize(dirty, {RETURN_TRUSTED_TYPE: true}); // will return a TrustedHTML object instead of a string if possible
293
293
 
294
+ // use a provided Trusted Types policy
295
+ var clean = DOMPurify.sanitize(dirty, {
296
+ // supplied policy must define createHTML and createScriptURL
297
+ TRUSTED_TYPES_POLICY: trustedTypes.createPolicy({
298
+ createHTML(s) { return s},
299
+ createScriptURL(s) { return s},
300
+ }
301
+ });
302
+
294
303
  /**
295
304
  * Influence how we sanitize
296
305
  */
@@ -301,8 +310,8 @@ var clean = DOMPurify.sanitize(dirty, {WHOLE_DOCUMENT: true});
301
310
  var clean = DOMPurify.sanitize(dirty, {SANITIZE_DOM: false});
302
311
 
303
312
  // enforce strict DOM Clobbering protection via namespace isolation (default is false)
304
- // when enabled, isolates the namespace of named properties (i.e., `id` and `name` attributes)
305
- // from JS variables by prefixing them with the string `user-content-`
313
+ // when enabled, isolates the namespace of named properties (i.e., `id` and `name` attributes)
314
+ // from JS variables by prefixing them with the string `user-content-`
306
315
  var clean = DOMPurify.sanitize(dirty, {SANITIZE_NAMED_PROPS: true});
307
316
 
308
317
  // keep an element's content when the element is removed (default is true)