This file is indexed.

/usr/share/javascript/htmlparser/htmlparser.min.js is in libjs-htmlparser 1.7.5+ds1-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
/***********************************************
Copyright 2010, 2011, Chris Winberry <chris@winberry.net>. All rights reserved.
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.
***********************************************//* v1.7.5 */(function(){function a(){return typeof require=="function"&&typeof exports=="object"&&typeof module=="object"&&typeof __filename=="string"&&typeof __dirname=="string"}function c(a,b){this._options=b?b:{},this._options.includeLocation==undefined&&(this._options.includeLocation=!1),this.validateHandler(a),this._handler=a,this.reset()}function d(a){d.super_.call(this,a,{ignoreWhitespace:!0,verbose:!1,enforceEmptyTags:!1})}function e(a,b){this.reset(),this._options=b?b:{},this._options.ignoreWhitespace==undefined&&(this._options.ignoreWhitespace=!1),this._options.verbose==undefined&&(this._options.verbose=!0),this._options.enforceEmptyTags==undefined&&(this._options.enforceEmptyTags=!0),typeof a=="function"&&(this._callback=a)}function g(a,b){var c=function(){};c.prototype=b.prototype,a.super_=b,a.prototype=new c,a.prototype.constructor=a}if(!a()){if(!this.Tautologistics)this.Tautologistics={};else if(this.Tautologistics.NodeHtmlParser)return;this.Tautologistics.NodeHtmlParser={},exports=this.Tautologistics.NodeHtmlParser}var b={Text:"text",Directive:"directive",Comment:"comment",Script:"script",Style:"style",Tag:"tag"};c._reTrim=/(^\s+|\s+$)/g,c._reTrimComment=/(^\!--|--$)/g,c._reWhitespace=/\s/g,c._reTagName=/^\s*(\/?)\s*([^\s\/]+)/,c._reAttrib=/([^=<>\"\'\s]+)\s*=\s*"([^"]*)"|([^=<>\"\'\s]+)\s*=\s*'([^']*)'|([^=<>\"\'\s]+)\s*=\s*([^'"\s]+)|([^=<>\"\'\s\/]+)/g,c._reTags=/[\<\>]/g,c.prototype.parseComplete=function(b){this.reset(),this.parseChunk(b),this.done()},c.prototype.parseChunk=function(b){this._done&&this.handleError(new Error("Attempted to parse chunk after parsing already done")),this._buffer+=b,this.parseTags()},c.prototype.done=function(){if(this._done)return;this._done=!0;if(this._buffer.length){var d=this._buffer;this._buffer="";var e={raw:d,data:this._parseState==b.Text?d:d.replace(c._reTrim,""),type:this._parseState};if(this._parseState==b.Tag||this._parseState==b.Script||this._parseState==b.Style)e.name=this.parseTagName(e.data);this.parseAttribs(e),this._elements.push(e)}this.writeHandler(),this._handler.done()},c.prototype.reset=function(){this._buffer="",this._done=!1,this._elements=[],this._elementsCurrent=0,this._current=0,this._next=0,this._location={row:0,col:0,charOffset:0,inBuffer:0},this._parseState=b.Text,this._prevTagSep="",this._tagStack=[],this._handler.reset()},c.prototype._options=null,c.prototype._handler=null,c.prototype._buffer=null,c.prototype._done=!1,c.prototype._elements=null,c.prototype._elementsCurrent=0,c.prototype._current=0,c.prototype._next=0,c.prototype._location=null,c.prototype._parseState=b.Text,c.prototype._prevTagSep="",c.prototype._tagStack=null,c.prototype.parseTagAttribs=function(c){var d=c.length,e=0;while(e<d){var f=c[e++];(f.type==b.Tag||f.type==b.Script||f.type==b.style)&&this.parseAttribs(f)}return c},c.prototype.parseAttribs=function(d){if(d.type!=b.Script&&d.type!=b.Style&&d.type!=b.Tag)return;var e=d.data.split(c._reWhitespace,1)[0],f=d.data.substring(e.length);if(f.length<1)return;var g;c._reAttrib.lastIndex=0;while(g=c._reAttrib.exec(f))d.attribs==undefined&&(d.attribs={}),typeof g[1]=="string"&&g[1].length?d.attribs[g[1]]=g[2]:typeof g[3]=="string"&&g[3].length?d.attribs[g[3].toString()]=g[4].toString():typeof g[5]=="string"&&g[5].length?d.attribs[g[5]]=g[6]:typeof g[7]=="string"&&g[7].length&&(d.attribs[g[7]]=g[7])},c.prototype.parseTagName=function(b){if(b==null||b=="")return"";var d=c._reTagName.exec(b);return d?(d[1]?"/":"")+d[2]:""},c.prototype.parseTags=function(){var d=this._buffer.length-1;while(c._reTags.test(this._buffer)){this._next=c._reTags.lastIndex-1;var e=this._buffer.charAt(this._next),f=this._buffer.substring(this._current,this._next),g={raw:f,data:this._parseState==b.Text?f:f.replace(c._reTrim,""),type:this._parseState},h=this.parseTagName(g.data);if(this._tagStack.length)if(this._tagStack[this._tagStack.length-1]==b.Script){if(h.toLowerCase()=="/script")this._tagStack.pop();else if(g.raw.indexOf("!--")!=0){g.type=b.Text;if(this._elements.length&&this._elements[this._elements.length-1].type==b.Text){var i=this._elements[this._elements.length-1];i.raw=i.data=i.raw+this._prevTagSep+g.raw,g.raw=g.data=""}}}else if(this._tagStack[this._tagStack.length-1]==b.Style){if(h.toLowerCase()=="/style")this._tagStack.pop();else if(g.raw.indexOf("!--")!=0){g.type=b.Text;if(this._elements.length&&this._elements[this._elements.length-1].type==b.Text){var i=this._elements[this._elements.length-1];g.raw!=""?(i.raw=i.data=i.raw+this._prevTagSep+g.raw,g.raw=g.data=""):i.raw=i.data=i.raw+this._prevTagSep}else g.raw!=""&&(g.raw=g.data=g.raw)}}else if(this._tagStack[this._tagStack.length-1]==b.Comment){var j=g.raw.length;if(g.raw.charAt(j-2)=="-"&&g.raw.charAt(j-1)=="-"&&e==">"){this._tagStack.pop();if(this._elements.length&&this._elements[this._elements.length-1].type==b.Comment){var i=this._elements[this._elements.length-1];i.raw=i.data=(i.raw+g.raw).replace(c._reTrimComment,""),g.raw=g.data="",g.type=b.Text}else g.type=b.Comment}else{g.type=b.Comment;if(this._elements.length&&this._elements[this._elements.length-1].type==b.Comment){var i=this._elements[this._elements.length-1];i.raw=i.data=i.raw+g.raw+e,g.raw=g.data="",g.type=b.Text}else g.raw=g.data=g.raw+e}}if(g.type==b.Tag){g.name=h;var k=h.toLowerCase();if(g.raw.indexOf("!--")==0){g.type=b.Comment,delete g.name;var j=g.raw.length;g.raw.charAt(j-1)=="-"&&g.raw.charAt(j-2)=="-"&&e==">"?g.raw=g.data=g.raw.replace(c._reTrimComment,""):(g.raw+=e,this._tagStack.push(b.Comment))}else g.raw.indexOf("!")==0||g.raw.indexOf("?")==0?g.type=b.Directive:k=="script"?(g.type=b.Script,g.data.charAt(g.data.length-1)!="/"&&this._tagStack.push(b.Script)):k=="/script"?g.type=b.Script:k=="style"?(g.type=b.Style,g.data.charAt(g.data.length-1)!="/"&&this._tagStack.push(b.Style)):k=="/style"&&(g.type=b.Style);g.name&&g.name.charAt(0)=="/"&&(g.data=g.name)}if(g.raw!=""||g.type!=b.Text)this._options.includeLocation&&!g.location&&(g.location=this.getLocation(g.type==b.Tag)),this.parseAttribs(g),this._elements.push(g),g.type!=b.Text&&g.type!=b.Comment&&g.type!=b.Directive&&g.data.charAt(g.data.length-1)=="/"&&this._elements.push({raw:"/"+g.name,data:"/"+g.name,name:"/"+g.name,type:g.type});this._parseState=e=="<"?b.Tag:b.Text,this._current=this._next+1,this._prevTagSep=e}this._options.includeLocation&&(this.getLocation(),this._location.row+=this._location.inBuffer,this._location.inBuffer=0,this._location.charOffset=0),this._buffer=this._current<=d?this._buffer.substring(this._current):"",this._current=0,this.writeHandler()},c.prototype.getLocation=function(b){var c,d=this._location,e=this._current-(b?1:0),f=b&&d.charOffset==0&&this._current==0;for(;d.charOffset<e;d.charOffset++)c=this._buffer.charAt(d.charOffset),c=="\n"?(d.inBuffer++,d.col=0):c!="\r"&&d.col++;return{line:d.row+d.inBuffer+1,col:d.col+(f?0:1)}},c.prototype.validateHandler=function(b){if(typeof b!="object")throw new Error("Handler is not an object");if(typeof b.reset!="function")throw new Error("Handler method 'reset' is invalid");if(typeof b.done!="function")throw new Error("Handler method 'done' is invalid");if(typeof b.writeTag!="function")throw new Error("Handler method 'writeTag' is invalid");if(typeof b.writeText!="function")throw new Error("Handler method 'writeText' is invalid");if(typeof b.writeComment!="function")throw new Error("Handler method 'writeComment' is invalid");if(typeof b.writeDirective!="function")throw new Error("Handler method 'writeDirective' is invalid")},c.prototype.writeHandler=function(c){c=!!c;if(this._tagStack.length&&!c)return;while(this._elements.length){var d=this._elements.shift();switch(d.type){case b.Comment:this._handler.writeComment(d);break;case b.Directive:this._handler.writeDirective(d);break;case b.Text:this._handler.writeText(d);break;default:this._handler.writeTag(d)}}},c.prototype.handleError=function(b){if(typeof this._handler.error!="function")throw b;this._handler.error(b)},g(d,e),d.prototype.done=function(){var b={},c,e=f.getElementsByTagName(function(a){return a=="rss"||a=="feed"},this.dom,!1);e.length&&(c=e[0]);if(c){if(c.name=="rss"){b.type="rss",c=c.children[0],b.id="";try{b.title=f.getElementsByTagName("title",c.children,!1)[0].children[0].data}catch(g){}try{b.link=f.getElementsByTagName("link",c.children,!1)[0].children[0].data}catch(g){}try{b.description=f.getElementsByTagName("description",c.children,!1)[0].children[0].data}catch(g){}try{b.updated=new Date(f.getElementsByTagName("lastBuildDate",c.children,!1)[0].children[0].data)}catch(g){}try{b.author=f.getElementsByTagName("managingEditor",c.children,!1)[0].children[0].data}catch(g){}b.items=[],f.getElementsByTagName("item",c.children).forEach(function(a,c,d){var e={};try{e.id=f.getElementsByTagName("guid",a.children,!1)[0].children[0].data}catch(g){}try{e.title=f.getElementsByTagName("title",a.children,!1)[0].children[0].data}catch(g){}try{e.link=f.getElementsByTagName("link",a.children,!1)[0].children[0].data}catch(g){}try{e.description=f.getElementsByTagName("description",a.children,!1)[0].children[0].data}catch(g){}try{e.pubDate=new Date(f.getElementsByTagName("pubDate",a.children,!1)[0].children[0].data)}catch(g){}b.items.push(e)})}else{b.type="atom";try{b.id=f.getElementsByTagName("id",c.children,!1)[0].children[0].data}catch(g){}try{b.title=f.getElementsByTagName("title",c.children,!1)[0].children[0].data}catch(g){}try{b.link=f.getElementsByTagName("link",c.children,!1)[0].attribs.href}catch(g){}try{b.description=f.getElementsByTagName("subtitle",c.children,!1)[0].children[0].data}catch(g){}try{b.updated=new Date(f.getElementsByTagName("updated",c.children,!1)[0].children[0].data)}catch(g){}try{b.author=f.getElementsByTagName("email",c.children,!0)[0].children[0].data}catch(g){}b.items=[],f.getElementsByTagName("entry",c.children).forEach(function(a,c,d){var e={};try{e.id=f.getElementsByTagName("id",a.children,!1)[0].children[0].data}catch(g){}try{e.title=f.getElementsByTagName("title",a.children,!1)[0].children[0].data}catch(g){}try{e.link=f.getElementsByTagName("link",a.children,!1)[0].attribs.href}catch(g){}try{e.description=f.getElementsByTagName("summary",a.children,!1)[0].children[0].data}catch(g){}try{e.pubDate=new Date(f.getElementsByTagName("updated",a.children,!1)[0].children[0].data)}catch(g){}b.items.push(e)})}this.dom=b}d.super_.prototype.done.call(this)},e._emptyTags={area:1,base:1,basefont:1,br:1,col:1,frame:1,hr:1,img:1,input:1,isindex:1,link:1,meta:1,param:1,embed:1},e.reWhitespace=/^\s*$/,e.prototype.dom=null,e.prototype.reset=function(){this.dom=[],this._done=!1,this._tagStack=[],this._tagStack.last=function(){return this.length?this[this.length-1]:null}},e.prototype.done=function(){this._done=!0,this.handleCallback(null)},e.prototype.writeTag=function(b){this.handleElement(b)},e.prototype.writeText=function(b){if(this._options.ignoreWhitespace&&e.reWhitespace.test(b.data))return;this.handleElement(b)},e.prototype.writeComment=function(b){this.handleElement(b)},e.prototype.writeDirective=function(b){this.handleElement(b)},e.prototype.error=function(b){this.handleCallback(b)},e.prototype._options=null,e.prototype._callback=null,e.prototype._done=!1,e.prototype._tagStack=null,e.prototype.handleCallback=function(b){if(typeof this._callback!="function"){if(b)throw b;return}this._callback(b,this.dom)},e.prototype.isEmptyTag=function(a){var b=a.name.toLowerCase();return b.charAt(0)=="/"&&(b=b.substring(1)),this._options.enforceEmptyTags&&!!e._emptyTags[b]},e.prototype.handleElement=function(c){this._done&&this.handleCallback(new Error("Writing to the handler after done() called is not allowed without a reset()")),this._options.verbose||(delete c.raw,(c.type=="tag"||c.type=="script"||c.type=="style")&&delete c.data);if(!this._tagStack.last())c.type!=b.Text&&c.type!=b.Comment&&c.type!=b.Directive?c.name.charAt(0)!="/"&&(this.dom.push(c),this.isEmptyTag(c)||this._tagStack.push(c)):this.dom.push(c);else if(c.type!=b.Text&&c.type!=b.Comment&&c.type!=b.Directive)if(c.name.charAt(0)=="/"){var d=c.name.substring(1);if(!this.isEmptyTag(c)){var e=this._tagStack.length-1;while(e>-1&&this._tagStack[e--].name!=d);if(e>-1||this._tagStack[0].name==d)while(e<this._tagStack.length-1)this._tagStack.pop()}}else this._tagStack.last().children||(this._tagStack.last().children=[]),this._tagStack.last().children.push(c),this.isEmptyTag(c)||this._tagStack.push(c);else this._tagStack.last().children||(this._tagStack.last().children=[]),this._tagStack.last().children.push(c)};var f={testElement:function(b,c){if(!c)return!1;for(var d in b)if(d=="tag_name"){if(c.type!="tag"&&c.type!="script"&&c.type!="style")return!1;if(!b.tag_name(c.name))return!1}else if(d=="tag_type"){if(!b.tag_type(c.type))return!1}else if(d=="tag_contains"){if(c.type!="text"&&c.type!="comment"&&c.type!="directive")return!1;if(!b.tag_contains(c.data))return!1}else if(!c.attribs||!b[d](c.attribs[d]))return!1;return!0},getElements:function(b,c,d,e){function i(a){return function(b){return b==a}}d=d===undefined||d===null||!!d,e=isNaN(parseInt(e))?-1:parseInt(e);if(!c)return[];var g=[],h;for(var j in b)typeof b[j]!="function"&&(b[j]=i(b[j]));f.testElement(b,c)&&g.push(c);if(e>=0&&g.length>=e)return g;if(d&&c.children)h=c.children;else{if(!(c instanceof Array))return g;h=c}for(var k=0;k<h.length;k++){g=g.concat(f.getElements(b,h[k],d,e));if(e>=0&&g.length>=e)break}return g},getElementById:function(b,c,d){var e=f.getElements({id:b},c,d,1);return e.length?e[0]:null},getElementsByTagName:function(b,c,d,e){return f.getElements({tag_name:b},c,d,e)},getElementsByTagType:function(b,c,d,e){return f.getElements({tag_type:b},c,d,e)}};exports.Parser=c,exports.DefaultHandler=e,exports.RssHandler=d,exports.ElementType=b,exports.DomUtils=f})();