| 1 | function sanitize( data, config ) |
| 2 | { |
| 3 | //Object and arrays |
| 4 | if( typeof( data ) == 'object' ) |
| 5 | { |
| 6 | for( let key in data ) |
| 7 | { |
| 8 | data[ key ] = sanitize( data[ key ], config ); |
| 9 | } |
| 10 | |
| 11 | return data; |
| 12 | } |
| 13 | |
| 14 | //String |
| 15 | if( typeof( data ) == 'string' ) |
| 16 | { |
| 17 | //config: e.g. { ALLOWED_TAGS: [] } |
| 18 | return DOMPurify.sanitize( data, config ); |
| 19 | } |
| 20 | else |
| 21 | { |
| 22 | return data; |
| 23 | } |
| 24 | } |
michelgentile / Sanitize
Last active 6 months ago
Revision 6a79a02a9461b3f83fab4962fd862c8f51cb8cb7