<commit_before>/*
  The MIT License (MIT)
  
  Copyright (c) 2015 <NAME>
  
  Permission is hereby granted, free of charge, to any person obtaining a copy
  of this software and associated documentation files (the "Software"), to deal
  in the Software without restriction, including without limitation the rights
  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  copies of the Software, and to permit persons to whom the Software is
  furnished to do so, subject to the following conditions:
  
  The above copyright notice and this permission notice shall be included in all
  copies or substantial portions of the Software.
  
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  SOFTWARE.
*/
/*
  - Anti XSS Protection Module - --------------------
  Author: <NAME> <<EMAIL>>
  - ---------------------------- --------------------
  Disclaimer:
  This module utilizes a doze of insanity and a drop of blood from the Black Witch of the North to bring joy to your divs and html elements without the hassle of unwanted magic spells and bacteria incorporated with your non-sanitary method of sanitization. Thus it is highly experimental to the extent that even this sentence is currently being tested in our non-existent laboratory which I will assure you is experimental itself. Use it at your own risk.
  - -------------------------- - --------------------
*/

"use strict";

(function () {
  // Define a unique variable for DOMParser & XMLSerializer to prevent collisions
  var ANTI_DOM_PARSER, ANTI_DOM_SERIALIZER;
  // Determines which Parser (NodeJS:xmldom->DOMParser, Browsers:DOMParser) to attach to our unique variable
  if (typeof DOMParser === "undefined") ANTI_DOM_PARSER = require('xmldom').DOMParser;
  else ANTI_DOM_PARSER = DOMParser;
  // Determines which Serializer (NodeJS:xmldom->XMLSerializer, Browsers:XMLSerializer) to attach to our unique variable
  if (typeof XMLSerializer === "undefined") ANTI_DOM_SERIALIZER = require('xmldom').XMLSerializer;
  else ANTI_DOM_SERIALIZER = XMLSerializer || Function;
  
  // Weirdly wrap Anti around Module definition
  var Module = (function () {
    var Anti = function ANTI_LOCAL(options) {
      this.Options = options || {};
      // Set Default Serializer to true
      if(!this.Options.serializer) this.Options.serializer = true;
      
      this.Parser = new ANTI_DOM_PARSER({
        errorHandler: {
          warning: new Function,
          error: new Function,
          fatalError: new Function
        }
      });
      /* Should throw if method serializeToString does not exist */
      this.Serializer = new ANTI_DOM_SERIALIZER();
      
      /// - DOM SAFELIST - ///
      /* Add support for SVG */
      /* Kills data attributes */
      this.ACCEPTABLE_BLOCK_ELEMENTS = ["#text", "a", "abbr", "acronym", "address", "article", "aside", "b", "bdi", "bdo", "big", "blockquote", "br", "caption", "center", "cite", "code", "colgroup", "dd", "del", "del", "dfn", "dir", "div", "dl", "dt", "em", "figcaption", "figure", "font", "footer", "h1", "h2", "h3", "h4", "h5", "h6", "header", "hgroup", "hr", "i", "img", "ins", "ins", "kbd", "label", "li", "map", "map", "mark", "menu", "nav", "ol", "p", "pre", "q", "rp", "rt", "ruby", "s", "samp", "section", "small", "span", "strike", "strong", "sub", "sup", "table", "tbody", "td", "tfoot", "th", "thead", "time", "tr", "tt", "u", "ul", "var"];
      this.ACCEPTABLE_SANITARY_ATTRIBUTES = ["abbr", "align", "alt", "axis", "bgcolor", "border", "cellpadding", "cellspacing", "class", "clear", "color", "cols", "colspan", "compact", "coords", "dir", "face", "headers", "height", "hreflang", "hspace", "ismap", "lang", "language", "nohref", "nowrap", "rel", "rev", "rows", "rowspan", "rules", "scope", "scrolling", "shape", "size", "span", "start", "summary", "tabindex", "target", "title", "type", "valign", "value", "vspace", "width"];

      this.ACCEPTABLE_UNSANITARY_ATTRIBUTES = ["background", "cite", "href", "longdesc", "src", "usemap", "style", "xlink:href"];
      /// - ------------ - ///
      /// - CSS SAFELIST - ///
      // This list is derived from document.createElement('div').style
      this.ACCEPTABLE_CSS_PROPERTIES = ["align-content", "align-items", "align-self", "alignment-baseline", "all", "animation", "animation-delay", "animation-direction", "animation-duration", "animation-fill-mode", "animation-iteration-count", "animation-name", "animation-play-state", "animation-timing-function", "backface-visibility", "background", "background-attachment", "background-blend-mode", "background-clip", "background-color", "background-image", "background-origin", "background-position", "background-position-x", "background-position-y", "background-repeat", "background-repeat-x", "background-repeat-y", "background-size", "baseline-shift", "border", "border-bottom", "border-bottom-color", "border-bottom-left-radius", "border-bottom-right-radius", "border-bottom-style", "border-bottom-width", "border-collapse", "border-color", "border-image", "border-image-outset", "border-image-repeat", "border-image-slice", "border-image-source", "border-image-width", "border-left", "border-left-color", "border-left-style", "border-left-width", "border-radius", "border-right", "border-right-color", "border-right-style", "border-right-width", "border-spacing", "border-style", "border-top", "border-top-color", "border-top-left-radius", "border-top-right-radius", "border-top-style", "border-top-width", "border-width", "bottom", "box-shadow", "box-sizing", "buffered-rendering", "caption-side", "clear", "clip", "clip-path", "clip-rule", "color", "color-interpolation", "color-interpolation-filters", "color-rendering", "content", "counter-increment", "counter-reset", "css-text", "cursor", "cx", "cy", "direction", "display", "dominant-baseline", "empty-cells", "enable-background", "fill", "fill-opacity", "fill-rule", "filter", "flex", "flex-basis", "flex-direction", "flex-flow", "flex-grow", "flex-shrink", "flex-wrap", "float", "flood-color", "flood-opacity", "font", "font-family", "font-kerning", "font-size", "font-stretch", "font-style", "font-variant", "font-variant-ligatures", "font-weight", "glyph-orientation-horizontal", "glyph-orientation-vertical", "height", "image-rendering", "isolation", "justify-content", "left", "length", "letter-spacing", "lighting-color", "line-height", "list-style", "list-style-image", "list-style-position", "list-style-type", "margin", "margin-bottom", "margin-left", "margin-right", "margin-top", "marker", "marker-end", "marker-mid", "marker-start", "mask", "mask-type", "max-height", "max-width", "max-zoom", "min-height", "min-width", "min-zoom", "mix-blend-mode", "object-fit", "object-position", "opacity", "order", "orientation", "orphans", "outline", "outline-color", "outline-offset", "outline-style", "outline-width", "overflow", "overflow-wrap", "overflow-x", "overflow-y", "padding", "padding-bottom", "padding-left", "padding-right", "padding-top", "page", "page-break-after", "page-break-before", "page-break-inside", "paint-order", "parent-rule", "null", "perspective", "perspective-origin", "pointer-events", "position", "quotes", "r", "resize", "right", "rx", "ry", "shape-image-threshold", "shape-margin", "shape-outside", "shape-rendering", "size", "speak", "src", "stop-color", "stop-opacity", "stroke", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity", "stroke-width", "tab-size", "table-layout", "text-align", "text-anchor", "text-decoration", "text-indent", "text-overflow", "text-rendering", "text-shadow", "text-transform", "top", "touch-action", "transform", "transform-origin", "transform-style", "transition", "transition-delay", "transition-duration", "transition-property", "transition-timing-function", "unicode-bidi", "unicode-range", "user-zoom", "vector-effect", "vertical-align", "visibility", "white-space", "widows", "width", "will-change", "word-break", "word-spacing", "word-wrap", "writing-mode", "x", "y", "z-index", "zoom"];
      /// - ------------ - ///
    };

    Anti.prototype.parse = function ANTI_PARSER(HTML_STRING, callback) {
      var ReturnAttributes = [];
      // Context
      var _this = this;
      
      // Clean Context
      this._DOCUMENT_ = null;
      this.root = null;
      
      // Populates this.root, this._DOCUMENT_
      this._parseToImmediateDOM(HTML_STRING.toString());
      
      // Copies all childen into variable DOM
      // Since the object above is not a simple JS Array (Should have a DOM-like structure on Browsers)
      // I took the liberty to copy only what we need into a clean Array
      this._cleanDOM(this.root, this._(this.root).children());
      this.root.attributes = {};
      
      /* Output a fixed root */

      var e = (this.Options.serialize) ? this.Serializer.serializeToString(this.root) : this.root;

      ReturnAttributes.push(e);
      
      // Allows for Async/Sync calls
      /* implement async functionality to forEach loops */
      if ((callback) && (callback.constructor === Function)) callback.apply(null, ReturnAttributes);
      else return (ReturnAttributes.length > 1) ? ReturnAttributes : ReturnAttributes[0];
    }

    Anti.prototype._parseToImmediateDOM = function ANTI_TO_IMMEDIATE(HTML_STRING) {
      this._DOCUMENT_ = this.Parser.parseFromString(HTML_STRING, "text/html");

      /* Test if this works in every case & if an attacker could confuse it */
      // Decide root from given document
      if (this._(this._DOCUMENT_.documentElement).tag === 'html') {
        /// ROOT TAG -> HTML
        var _this = this;
        // Find Body -> This works better on Browsers as they tend to
        // wrap the DOMParser output in a #document object
        this._(this._DOCUMENT_.documentElement).children().forEach(function (node) {
          if (node.tag === 'body') _this.root = node.node;
        })
      } else if (this._(this._DOCUMENT_.documentElement).tag === 'body') {
        /// ROOT TAG -> BODY
        this.root = this._DOCUMENT_.documentElement;
      } else {
        /// ROOT TAG -> ROOT
        this.root = this._DOCUMENT_;
      }
    };

    Anti.prototype._cleanDOM = function ANTI_TO_CLEAN(ROOT, DIRTYDOM) {
      var _this = this;
      
      /* Improve performance and reduce resources */
      // Poor man's cache solution (bad for GC, I know)
      var EL_ATTRIBUTES_CACHE = [];
      var CLEANDOM = [];
      
      /* Implement async method */
      // Heavily recursive
      DIRTYDOM.forEach(function (node, index) {
        // Check if element is acceptable
        if (_this._lookup(_this.ACCEPTABLE_BLOCK_ELEMENTS, node.tag)) {
          // CLEAN BLOCK : *Attributes might still be dirty
          EL_ATTRIBUTES_CACHE = node.attr();
          EL_ATTRIBUTES_CACHE.forEach(function (attr, index) {
            // REMOVE UNSANITARY ATTRIBUTES
            if (_this._lookup(_this.ACCEPTABLE_SANITARY_ATTRIBUTES, attr.name)) {
              // DO NOTHING FOR NOW - ATTR is acceptable
            } else if (_this._lookup(_this.ACCEPTABLE_UNSANITARY_ATTRIBUTES, attr.name)) {
              /* Add target:_blank to all a links */
              /* Add option for cross site linking/replacement */
              // Re-assign attribute with URL encoding
              node.removeAttribute(attr.name);
              /* Replace with inline-css xss protection */
              if (attr.name === 'style') {
                // If InlineCSS is enabled
                if(this.Options.experimentalInlineCSS) node.setAttribute(attr.name, _this._parseInlineCSS(attr.value));
              } else {
                node.setAttribute(attr.name, encodeURIComponent(attr.value));
              }
            } else {
              node.removeAttribute(attr.name);
            }
          })
          // Recursively clean children
          _this._cleanDOM(node, node.children());
          // PUSH CLEAN BLOCK
          CLEANDOM.push(node);<commit_msg>Fixed a context reference bug<commit_after>/*
  The MIT License (MIT)
  
  Copyright (c) 2015 <NAME>
  
  Permission is hereby granted, free of charge, to any person obtaining a copy
  of this software and associated documentation files (the "Software"), to deal
  in the Software without restriction, including without limitation the rights
  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  copies of the Software, and to permit persons to whom the Software is
  furnished to do so, subject to the following conditions:
  
  The above copyright notice and this permission notice shall be included in all
  copies or substantial portions of the Software.
  
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  SOFTWARE.
*/
/*
  - Anti XSS Protection Module - --------------------
  Author: <NAME> <<EMAIL>>
  - ---------------------------- --------------------
  Disclaimer:
  This module utilizes a doze of insanity and a drop of blood from the Black Witch of the North to bring joy to your divs and html elements without the hassle of unwanted magic spells and bacteria incorporated with your non-sanitary method of sanitization. Thus it is highly experimental to the extent that even this sentence is currently being tested in our non-existent laboratory which I will assure you is experimental itself. Use it at your own risk.
  - -------------------------- - --------------------
*/

"use strict";

(function () {
  // Define a unique variable for DOMParser & XMLSerializer to prevent collisions
  var ANTI_DOM_PARSER, ANTI_DOM_SERIALIZER;
  // Determines which Parser (NodeJS:xmldom->DOMParser, Browsers:DOMParser) to attach to our unique variable
  if (typeof DOMParser === "undefined") ANTI_DOM_PARSER = require('xmldom').DOMParser;
  else ANTI_DOM_PARSER = DOMParser;
  // Determines which Serializer (NodeJS:xmldom->XMLSerializer, Browsers:XMLSerializer) to attach to our unique variable
  if (typeof XMLSerializer === "undefined") ANTI_DOM_SERIALIZER = require('xmldom').XMLSerializer;
  else ANTI_DOM_SERIALIZER = XMLSerializer || Function;
  
  // Weirdly wrap Anti around Module definition
  var Module = (function () {
    var Anti = function ANTI_LOCAL(options) {
      this.Options = options || {};
      // Set Default Serializer to true
      if(!this.Options.serializer) this.Options.serializer = true;
      
      this.Parser = new ANTI_DOM_PARSER({
        errorHandler: {
          warning: new Function,
          error: new Function,
          fatalError: new Function
        }
      });
      /* Should throw if method serializeToString does not exist */
      this.Serializer = new ANTI_DOM_SERIALIZER();
      
      /// - DOM SAFELIST - ///
      /* Add support for SVG */
      /* Kills data attributes */
      this.ACCEPTABLE_BLOCK_ELEMENTS = ["#text", "a", "abbr", "acronym", "address", "article", "aside", "b", "bdi", "bdo", "big", "blockquote", "br", "caption", "center", "cite", "code", "colgroup", "dd", "del", "del", "dfn", "dir", "div", "dl", "dt", "em", "figcaption", "figure", "font", "footer", "h1", "h2", "h3", "h4", "h5", "h6", "header", "hgroup", "hr", "i", "img", "ins", "ins", "kbd", "label", "li", "map", "map", "mark", "menu", "nav", "ol", "p", "pre", "q", "rp", "rt", "ruby", "s", "samp", "section", "small", "span", "strike", "strong", "sub", "sup", "table", "tbody", "td", "tfoot", "th", "thead", "time", "tr", "tt", "u", "ul", "var"];
      this.ACCEPTABLE_SANITARY_ATTRIBUTES = ["abbr", "align", "alt", "axis", "bgcolor", "border", "cellpadding", "cellspacing", "class", "clear", "color", "cols", "colspan", "compact", "coords", "dir", "face", "headers", "height", "hreflang", "hspace", "ismap", "lang", "language", "nohref", "nowrap", "rel", "rev", "rows", "rowspan", "rules", "scope", "scrolling", "shape", "size", "span", "start", "summary", "tabindex", "target", "title", "type", "valign", "value", "vspace", "width"];

      this.ACCEPTABLE_UNSANITARY_ATTRIBUTES = ["background", "cite", "href", "longdesc", "src", "usemap", "style", "xlink:href"];
      /// - ------------ - ///
      /// - CSS SAFELIST - ///
      // This list is derived from document.createElement('div').style
      this.ACCEPTABLE_CSS_PROPERTIES = ["align-content", "align-items", "align-self", "alignment-baseline", "all", "animation", "animation-delay", "animation-direction", "animation-duration", "animation-fill-mode", "animation-iteration-count", "animation-name", "animation-play-state", "animation-timing-function", "backface-visibility", "background", "background-attachment", "background-blend-mode", "background-clip", "background-color", "background-image", "background-origin", "background-position", "background-position-x", "background-position-y", "background-repeat", "background-repeat-x", "background-repeat-y", "background-size", "baseline-shift", "border", "border-bottom", "border-bottom-color", "border-bottom-left-radius", "border-bottom-right-radius", "border-bottom-style", "border-bottom-width", "border-collapse", "border-color", "border-image", "border-image-outset", "border-image-repeat", "border-image-slice", "border-image-source", "border-image-width", "border-left", "border-left-color", "border-left-style", "border-left-width", "border-radius", "border-right", "border-right-color", "border-right-style", "border-right-width", "border-spacing", "border-style", "border-top", "border-top-color", "border-top-left-radius", "border-top-right-radius", "border-top-style", "border-top-width", "border-width", "bottom", "box-shadow", "box-sizing", "buffered-rendering", "caption-side", "clear", "clip", "clip-path", "clip-rule", "color", "color-interpolation", "color-interpolation-filters", "color-rendering", "content", "counter-increment", "counter-reset", "css-text", "cursor", "cx", "cy", "direction", "display", "dominant-baseline", "empty-cells", "enable-background", "fill", "fill-opacity", "fill-rule", "filter", "flex", "flex-basis", "flex-direction", "flex-flow", "flex-grow", "flex-shrink", "flex-wrap", "float", "flood-color", "flood-opacity", "font", "font-family", "font-kerning", "font-size", "font-stretch", "font-style", "font-variant", "font-variant-ligatures", "font-weight", "glyph-orientation-horizontal", "glyph-orientation-vertical", "height", "image-rendering", "isolation", "justify-content", "left", "length", "letter-spacing", "lighting-color", "line-height", "list-style", "list-style-image", "list-style-position", "list-style-type", "margin", "margin-bottom", "margin-left", "margin-right", "margin-top", "marker", "marker-end", "marker-mid", "marker-start", "mask", "mask-type", "max-height", "max-width", "max-zoom", "min-height", "min-width", "min-zoom", "mix-blend-mode", "object-fit", "object-position", "opacity", "order", "orientation", "orphans", "outline", "outline-color", "outline-offset", "outline-style", "outline-width", "overflow", "overflow-wrap", "overflow-x", "overflow-y", "padding", "padding-bottom", "padding-left", "padding-right", "padding-top", "page", "page-break-after", "page-break-before", "page-break-inside", "paint-order", "parent-rule", "null", "perspective", "perspective-origin", "pointer-events", "position", "quotes", "r", "resize", "right", "rx", "ry", "shape-image-threshold", "shape-margin", "shape-outside", "shape-rendering", "size", "speak", "src", "stop-color", "stop-opacity", "stroke", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity", "stroke-width", "tab-size", "table-layout", "text-align", "text-anchor", "text-decoration", "text-indent", "text-overflow", "text-rendering", "text-shadow", "text-transform", "top", "touch-action", "transform", "transform-origin", "transform-style", "transition", "transition-delay", "transition-duration", "transition-property", "transition-timing-function", "unicode-bidi", "unicode-range", "user-zoom", "vector-effect", "vertical-align", "visibility", "white-space", "widows", "width", "will-change", "word-break", "word-spacing", "word-wrap", "writing-mode", "x", "y", "z-index", "zoom"];
      /// - ------------ - ///
    };

    Anti.prototype.parse = function ANTI_PARSER(HTML_STRING, callback) {
      var ReturnAttributes = [];
      // Context
      var _this = this;
      
      // Clean Context
      this._DOCUMENT_ = null;
      this.root = null;
      
      // Populates this.root, this._DOCUMENT_
      this._parseToImmediateDOM(HTML_STRING.toString());
      
      // Copies all childen into variable DOM
      // Since the object above is not a simple JS Array (Should have a DOM-like structure on Browsers)
      // I took the liberty to copy only what we need into a clean Array
      this._cleanDOM(this.root, this._(this.root).children());
      this.root.attributes = {};
      
      /* Output a fixed root */

      var e = (this.Options.serialize) ? this.Serializer.serializeToString(this.root) : this.root;

      ReturnAttributes.push(e);
      
      // Allows for Async/Sync calls
      /* implement async functionality to forEach loops */
      if ((callback) && (callback.constructor === Function)) callback.apply(null, ReturnAttributes);
      else return (ReturnAttributes.length > 1) ? ReturnAttributes : ReturnAttributes[0];
    }

    Anti.prototype._parseToImmediateDOM = function ANTI_TO_IMMEDIATE(HTML_STRING) {
      this._DOCUMENT_ = this.Parser.parseFromString(HTML_STRING, "text/html");

      /* Test if this works in every case & if an attacker could confuse it */
      // Decide root from given document
      if (this._(this._DOCUMENT_.documentElement).tag === 'html') {
        /// ROOT TAG -> HTML
        var _this = this;
        // Find Body -> This works better on Browsers as they tend to
        // wrap the DOMParser output in a #document object
        this._(this._DOCUMENT_.documentElement).children().forEach(function (node) {
          if (node.tag === 'body') _this.root = node.node;
        })
      } else if (this._(this._DOCUMENT_.documentElement).tag === 'body') {
        /// ROOT TAG -> BODY
        this.root = this._DOCUMENT_.documentElement;
      } else {
        /// ROOT TAG -> ROOT
        this.root = this._DOCUMENT_;
      }
    };

    Anti.prototype._cleanDOM = function ANTI_TO_CLEAN(ROOT, DIRTYDOM) {
      var _this = this;
      
      /* Improve performance and reduce resources */
      // Poor man's cache solution (bad for GC, I know)
      var EL_ATTRIBUTES_CACHE = [];
      var CLEANDOM = [];
      
      /* Implement async method */
      // Heavily recursive
      DIRTYDOM.forEach(function (node, index) {
        // Check if element is acceptable
        if (_this._lookup(_this.ACCEPTABLE_BLOCK_ELEMENTS, node.tag)) {
          // CLEAN BLOCK : *Attributes might still be dirty
          EL_ATTRIBUTES_CACHE = node.attr();
          EL_ATTRIBUTES_CACHE.forEach(function (attr, index) {
            // REMOVE UNSANITARY ATTRIBUTES
            if (_this._lookup(_this.ACCEPTABLE_SANITARY_ATTRIBUTES, attr.name)) {
              // DO NOTHING FOR NOW - ATTR is acceptable
            } else if (_this._lookup(_this.ACCEPTABLE_UNSANITARY_ATTRIBUTES, attr.name)) {
              /* Add target:_blank to all a links */
              /* Add option for cross site linking/replacement */
              // Re-assign attribute with URL encoding
              node.removeAttribute(attr.name);
              /* Replace with inline-css xss protection */
              if (attr.name === 'style') {
                // If InlineCSS is enabled
                if(_this.Options.experimentalInlineCSS) node.setAttribute(attr.name, _this._parseInlineCSS(attr.value));
              } else {
                node.setAttribute(attr.name, encodeURIComponent(attr.value));
              }
            } else {
              node.removeAttribute(attr.name);
            }
          })
          // Recursively clean children
          _this._cleanDOM(node, node.children());
          // PUSH CLEAN BLOCK
          CLEANDOM.push(node);
{'fraction_non_alphanumeric': 0.17274084836743755, 'fraction_numerical': 0.000968640271219276, 'mean_word_length': 3.422273781902552, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 8}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3530518', 'n_tokens_mistral': 7417, 'n_tokens_neox': 7234, 'n_words': 2073}