Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

xmldom

Package Overview
Dependencies
Maintainers
5
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

xmldom - npm Package Compare versions

Comparing version 0.1.22 to 0.1.24

46

dom-parser.js

@@ -5,3 +5,3 @@ function DOMParser(options){

}
DOMParser.prototype.parseFromString = function(source,mimeType){
DOMParser.prototype.parseFromString = function(source,mimeType){
var options = this.options;

@@ -29,5 +29,5 @@ var sax = new XMLReader();

}else{
sax.errorHandler.error("invalid document source");
sax.errorHandler.error("invalid doc source");
}
return domBuilder.document;
return domBuilder.doc;
}

@@ -82,9 +82,9 @@ function buildErrorHandler(errorImpl,domBuilder,locator){

startDocument : function() {
this.document = new DOMImplementation().createDocument(null, null, null);
this.doc = new DOMImplementation().createDocument(null, null, null);
if (this.locator) {
this.document.documentURI = this.locator.systemId;
this.doc.documentURI = this.locator.systemId;
}
},
startElement:function(namespaceURI, localName, qName, attrs) {
var doc = this.document;
var doc = this.doc;
var el = doc.createElementNS(namespaceURI, qName||localName);

@@ -101,5 +101,3 @@ var len = attrs.length;

var attr = doc.createAttributeNS(namespaceURI, qName);
if( attr.getOffset){
position(attr.getOffset(1),attr)
}
this.locator &&position(attrs.getLocator(i),attr);
attr.value = attr.nodeValue = value;

@@ -111,4 +109,4 @@ el.setAttributeNode(attr)

var current = this.currentElement
var tagName = current.tagName;
this.currentElement = current.parentNode;
var tagName = current.tagName;
this.currentElement = current.parentNode;
},

@@ -120,3 +118,3 @@ startPrefixMapping:function(prefix, uri) {

processingInstruction:function(target, data) {
var ins = this.document.createProcessingInstruction(target, data);
var ins = this.doc.createProcessingInstruction(target, data);
this.locator && position(this.locator,ins)

@@ -130,9 +128,13 @@ appendElement(this, ins);

//console.log(chars)
if(this.currentElement && chars){
if(chars){
if (this.cdata) {
var charNode = this.document.createCDATASection(chars);
this.currentElement.appendChild(charNode);
var charNode = this.doc.createCDATASection(chars);
} else {
var charNode = this.document.createTextNode(chars);
var charNode = this.doc.createTextNode(chars);
}
if(this.currentElement){
this.currentElement.appendChild(charNode);
}else if(/^\s*$/.test(chars)){
this.doc.appendChild(charNode);
//process xml
}

@@ -145,3 +147,3 @@ this.locator && position(this.locator,charNode)

endDocument:function() {
this.document.normalize();
this.doc.normalize();
},

@@ -156,3 +158,3 @@ setDocumentLocator:function (locator) {

chars = _toString.apply(this,arguments)
var comm = this.document.createComment(chars);
var comm = this.doc.createComment(chars);
this.locator && position(this.locator,comm)

@@ -171,3 +173,3 @@ appendElement(this, comm);

startDTD:function(name, publicId, systemId) {
var impl = this.document.implementation;
var impl = this.doc.implementation;
if (impl && impl.createDocumentType) {

@@ -248,3 +250,3 @@ var dt = impl.createDocumentType(name, publicId, systemId);

if (!hander.currentElement) {
hander.document.appendChild(node);
hander.doc.appendChild(node);
} else {

@@ -255,3 +257,3 @@ hander.currentElement.appendChild(node);

if(typeof require == 'function'){
//if(typeof require == 'function'){
var XMLReader = require('./sax').XMLReader;

@@ -261,2 +263,2 @@ var DOMImplementation = exports.DOMImplementation = require('./dom').DOMImplementation;

exports.DOMParser = DOMParser;
}
//}

@@ -113,5 +113,5 @@ /*

},
toString:function(){
toString:function(isHTML,nodeFilter){
for(var buf = [], i = 0;i<this.length;i++){
serializeToString(this[i],buf);
serializeToString(this[i],buf,isHTML,nodeFilter);
}

@@ -174,2 +174,3 @@ return buf.join('');

function _removeNamedNode(el,list,attr){
//console.log('remove attr:'+attr)
var i = _findNodeIndex(list,attr);

@@ -190,3 +191,3 @@ if(i>=0){

}else{
throw DOMException(NOT_FOUND_ERR,new Error())
throw DOMException(NOT_FOUND_ERR,new Error(el.tagName+'@'+attr))
}

@@ -201,5 +202,7 @@ }

// }
//console.log()
var i = this.length;
while(i--){
var attr = this[i];
//console.log(attr.nodeName,key)
if(attr.nodeName == key){

@@ -386,3 +389,3 @@ return attr;

}
el = el.nodeType == 2?el.ownerDocument : el.parentNode;
el = el.nodeType == ATTRIBUTE_NODE?el.ownerDocument : el.parentNode;
}

@@ -402,3 +405,3 @@ return null;

}
el = el.nodeType == 2?el.ownerDocument : el.parentNode;
el = el.nodeType == ATTRIBUTE_NODE?el.ownerDocument : el.parentNode;
}

@@ -588,3 +591,3 @@ return null;

}
if(this.documentElement == null && newChild.nodeType == 1){
if(this.documentElement == null && newChild.nodeType == ELEMENT_NODE){
this.documentElement = newChild;

@@ -609,3 +612,3 @@ }

_visitNode(this.documentElement,function(node){
if(node.nodeType == 1){
if(node.nodeType == ELEMENT_NODE){
if(node.getAttribute('id') == id){

@@ -759,2 +762,3 @@ rtv = node;

removeAttributeNode : function(oldAttr){
//console.log(this == oldAttr.ownerElement)
return this.attributes.removeNamedItem(oldAttr.nodeName);

@@ -804,2 +808,3 @@ },

return ls;
});

@@ -921,13 +926,72 @@ }

function XMLSerializer(){}
XMLSerializer.prototype.serializeToString = function(node,attributeSorter){
return node.toString(attributeSorter);
XMLSerializer.prototype.serializeToString = function(node,isHtml,nodeFilter){
return nodeSerializeToString.call(node,isHtml,nodeFilter);
}
Node.prototype.toString =function(attributeSorter){
Node.prototype.toString = nodeSerializeToString;
function nodeSerializeToString(isHtml,nodeFilter){
var buf = [];
serializeToString(this,buf,attributeSorter);
var refNode = this.nodeType == 9?this.documentElement:this;
var prefix = refNode.prefix;
var uri = refNode.namespaceURI;
if(uri && prefix == null){
//console.log(prefix)
var prefix = refNode.lookupPrefix(uri);
if(prefix == null){
//isHTML = true;
var visibleNamespaces=[
{namespace:uri,prefix:null}
//{namespace:uri,prefix:''}
]
}
}
serializeToString(this,buf,isHtml,nodeFilter,visibleNamespaces);
//console.log('###',this.nodeType,uri,prefix,buf.join(''))
return buf.join('');
}
function serializeToString(node,buf,attributeSorter,isHTML){
function needNamespaceDefine(node,isHTML, visibleNamespaces) {
var prefix = node.prefix,uri = node.namespaceURI;
if (!prefix && !uri){
return false;
}
if (prefix === "xml" && uri === "http://www.w3.org/XML/1998/namespace"
|| uri == 'http://www.w3.org/2000/xmlns/'){
return false;
}
var i = visibleNamespaces.length
//console.log('@@@@',node.tagName,prefix,uri,visibleNamespaces)
while (i--) {
var ns = visibleNamespaces[i];
// get namespace prefix
//console.log(node.nodeType,node.tagName,ns.prefix,prefix)
if (ns.prefix == prefix){
return ns.namespace != uri;
}
}
//console.log(isHTML,uri,prefix=='')
//if(isHTML && prefix ==null && uri == 'http://www.w3.org/1999/xhtml'){
// return false;
//}
//node.flag = '11111'
//console.error(3,true,node.flag,node.prefix,node.namespaceURI)
return true;
}
function serializeToString(node,buf,isHTML,nodeFilter,visibleNamespaces){
if(nodeFilter){
node = nodeFilter(node);
if(node){
if(typeof node == 'string'){
buf.push(node);
return;
}
}else{
return;
}
//buf.sort.apply(attrs, attributeSorter);
}
switch(node.nodeType){
case ELEMENT_NODE:
if (!visibleNamespaces) visibleNamespaces = [];
var startVisibleNamespaces = visibleNamespaces.length;
var attrs = node.attributes;

@@ -937,20 +1001,47 @@ var len = attrs.length;

var nodeName = node.tagName;
isHTML = (htmlns === node.namespaceURI) ||isHTML
buf.push('<',nodeName);
if(attributeSorter){
buf.sort.apply(attrs, attributeSorter);
for(var i=0;i<len;i++){
// add namespaces for attributes
var attr = attrs.item(i);
if (attr.prefix == 'xmlns') {
visibleNamespaces.push({ prefix: attr.localName, namespace: attr.value });
}else if(attr.nodeName == 'xmlns'){
visibleNamespaces.push({ prefix: '', namespace: attr.value });
}
}
for(var i=0;i<len;i++){
serializeToString(attrs.item(i),buf,attributeSorter,isHTML);
var attr = attrs.item(i);
if (needNamespaceDefine(attr,isHTML, visibleNamespaces)) {
buf.push(attr.prefix ? ' xmlns:' + attr.prefix : " xmlns", "='" , attr.namespaceURI , "'");
visibleNamespaces.push({ prefix: attr.prefix, namespace: attr.namespaceURI });
}
serializeToString(attr,buf,isHTML,nodeFilter,visibleNamespaces);
}
if(child || isHTML && !/^(?:meta|link|img|br|hr|input|button)$/i.test(nodeName)){
// add namespace for current node
if (needNamespaceDefine(node,isHTML, visibleNamespaces)) {
buf.push(node.prefix ? ' xmlns:' + node.prefix : " xmlns", "='" , node.namespaceURI , "'");
visibleNamespaces.push({ prefix: node.prefix, namespace: node.namespaceURI });
}
if(child || isHTML && !/^(?:meta|link|img|br|hr|input)$/i.test(nodeName)){
buf.push('>');
//if is cdata child node
if(isHTML && /^script$/i.test(nodeName)){
if(child){
buf.push(child.data);
while(child){
if(child.data){
buf.push(child.data);
}else{
serializeToString(child,buf,isHTML,nodeFilter,visibleNamespaces);
}
child = child.nextSibling;
}
}else{
}else
{
while(child){
serializeToString(child,buf,attributeSorter,isHTML);
serializeToString(child,buf,isHTML,nodeFilter,visibleNamespaces);
child = child.nextSibling;

@@ -963,2 +1054,4 @@ }

}
// remove added visible namespaces
//visibleNamespaces.length = startVisibleNamespaces;
return;

@@ -969,3 +1062,3 @@ case DOCUMENT_NODE:

while(child){
serializeToString(child,buf,attributeSorter,isHTML);
serializeToString(child,buf,isHTML,nodeFilter,visibleNamespaces);
child = child.nextSibling;

@@ -1115,4 +1208,4 @@ }

switch(this.nodeType){
case 1:
case 11:
case ELEMENT_NODE:
case DOCUMENT_FRAGMENT_NODE:
while(this.firstChild){

@@ -1128,3 +1221,3 @@ this.removeChild(this.firstChild);

this.data = data;
this.value = value;
this.value = data;
this.nodeValue = data;

@@ -1137,4 +1230,4 @@ }

switch(node.nodeType){
case 1:
case 11:
case ELEMENT_NODE:
case DOCUMENT_FRAGMENT_NODE:
var buf = [];

@@ -1161,5 +1254,5 @@ node = node.firstChild;

if(typeof require == 'function'){
//if(typeof require == 'function'){
exports.DOMImplementation = DOMImplementation;
exports.XMLSerializer = XMLSerializer;
}
//}
{
"name": "xmldom",
"version": "0.1.22",
"version": "0.1.24",
"description": "A W3C Standard XML DOM(Level2 CORE) implementation and parser(DOMParser/XMLSerializer).",

@@ -5,0 +5,0 @@ "keywords": ["w3c","dom","xml","parser","javascript","DOMParser","XMLSerializer"],

@@ -5,3 +5,3 @@ //[4] NameStartChar ::= ":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF] | [#x370-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]

var nameStartChar = /[A-Z_a-z\xC0-\xD6\xD8-\xF6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]///\u10000-\uEFFFF
var nameChar = new RegExp("[\\-\\.0-9"+nameStartChar.source.slice(1,-1)+"\u00B7\u0300-\u036F\\u203F-\u2040]");
var nameChar = new RegExp("[\\-\\.0-9"+nameStartChar.source.slice(1,-1)+"\\u00B7\\u0300-\\u036F\\u203F-\\u2040]");
var tagNamePattern = new RegExp('^'+nameStartChar.source+nameChar.source+'*(?:\:'+nameStartChar.source+nameChar.source+'*)?$');

@@ -11,12 +11,12 @@ //var tagNamePattern = /^[a-zA-Z_][\w\-\.]*(?:\:[a-zA-Z_][\w\-\.]*)?$/

//S_TAG, S_ATTR, S_EQ, S_V
//S_ATTR_S, S_E, S_S, S_C
//S_TAG, S_ATTR, S_EQ, S_ATTR_NOQUOT_VALUE
//S_ATTR_SPACE, S_ATTR_END, S_TAG_SPACE, S_TAG_CLOSE
var S_TAG = 0;//tag name offerring
var S_ATTR = 1;//attr name offerring
var S_ATTR_S=2;//attr name end and space offer
var S_ATTR_SPACE=2;//attr name end and space offer
var S_EQ = 3;//=space?
var S_V = 4;//attr value(no quot value only)
var S_E = 5;//attr value end and no space(quot end)
var S_S = 6;//(attr value end || tag end ) && (space offer)
var S_C = 7;//closed el<el />
var S_ATTR_NOQUOT_VALUE = 4;//attr value(no quot value only)
var S_ATTR_END = 5;//attr value end and no space(quot end)
var S_TAG_SPACE = 6;//(attr value end || tag end ) && (space offer)
var S_TAG_CLOSE = 7;//closed el<el />

@@ -38,3 +38,3 @@ function XMLReader(){

function parse(source,defaultNSMapCopy,entityMap,domBuilder,errorHandler){
function fixedFromCharCode(code) {
function fixedFromCharCode(code) {
// String.prototype.fromCharCode does not supports

@@ -82,3 +82,3 @@ // > 2 bytes unicode chars directly

var lineEnd = 0;
var linePattern = /.+(?:\r\n?|\n)|.*$/g
var linePattern = /.*(?:\r\n?|\n)|.*$/g
var locator = domBuilder.locator;

@@ -94,3 +94,3 @@

if(!source.substr(start).match(/^\s*$/)){
var doc = domBuilder.document;
var doc = domBuilder.doc;
var text = doc.createTextNode(source.substr(start));

@@ -110,12 +110,32 @@ doc.appendChild(text);

var config = parseStack.pop();
if(end<0){
tagName = source.substring(tagStart+2).replace(/[\s<].*/,'');
//console.error('#@@@@@@'+tagName)
errorHandler.error("end tag name: "+tagName+' is not complete:'+config.tagName);
end = tagStart+1+tagName.length;
}else if(tagName.match(/\s</)){
tagName = tagName.replace(/[\s<].*/,'');
errorHandler.error("end tag name: "+tagName+' maybe not complete');
end = tagStart+1+tagName.length;
}
//console.error(parseStack.length,parseStack)
//console.error(config);
var localNSMap = config.localNSMap;
if(config.tagName != tagName){
errorHandler.fatalError("end tag name: "+tagName+' is not match the current start tagName:'+config.tagName );
var endMatch = config.tagName == tagName;
var endIgnoreCaseMach = endMatch || config.tagName&&config.tagName.toLowerCase() == tagName.toLowerCase()
if(endIgnoreCaseMach){
domBuilder.endElement(config.uri,config.localName,tagName);
if(localNSMap){
for(var prefix in localNSMap){
domBuilder.endPrefixMapping(prefix) ;
}
}
if(!endMatch){
errorHandler.fatalError("end tag name: "+tagName+' is not match the current start tagName:'+config.tagName );
}
}else{
parseStack.push(config)
}
domBuilder.endElement(config.uri,config.localName,tagName);
if(localNSMap){
for(var prefix in localNSMap){
domBuilder.endPrefixMapping(prefix) ;
}
}
end++;

@@ -133,22 +153,10 @@ break;

default:
locator&&position(tagStart);
var el = new ElementAttributes();
var currentNSMap = parseStack[parseStack.length-1].currentNSMap;
//elStartEnd
var end = parseElementStartPart(source,tagStart,el,entityReplacer,errorHandler);
var end = parseElementStartPart(source,tagStart,el,currentNSMap,entityReplacer,errorHandler);
var len = el.length;
if(locator){
if(len){
//attribute position fixed
for(var i = 0;i<len;i++){
var a = el[i];
position(a.offset);
a.offset = copyLocator(locator,{});
}
}
position(end);
}
if(!el.closed && fixSelfClosed(source,end,el.tagName,closeMap)){

@@ -160,5 +168,24 @@ el.closed = true;

}
appendElement(el,domBuilder,parseStack);
if(locator && len){
var locator2 = copyLocator(locator,{});
//try{//attribute position fixed
for(var i = 0;i<len;i++){
var a = el[i];
position(a.offset);
a.locator = copyLocator(locator,{});
}
//}catch(e){console.error('@@@@@'+e)}
domBuilder.locator = locator2
if(appendElement(el,domBuilder,currentNSMap)){
parseStack.push(el)
}
domBuilder.locator = locator;
}else{
if(appendElement(el,domBuilder,currentNSMap)){
parseStack.push(el)
}
}
if(el.uri === 'http://www.w3.org/1999/xhtml' && !el.closed){

@@ -171,4 +198,6 @@ end = parseHtmlSpecialContent(source,end,el.tagName,entityReplacer,domBuilder)

}catch(e){
errorHandler.error('element parse error: '+e);
errorHandler.error('element parse error: '+e)
//errorHandler.error('element parse error: '+e);
end = -1;
//throw e;
}

@@ -193,3 +222,3 @@ if(end>start){

*/
function parseElementStartPart(source,start,el,entityReplacer,errorHandler){
function parseElementStartPart(source,start,el,currentNSMap,entityReplacer,errorHandler){
var attrName;

@@ -206,3 +235,3 @@ var value;

s = S_EQ;
}else if(s === S_ATTR_S){
}else if(s === S_ATTR_SPACE){
s = S_EQ;

@@ -216,3 +245,8 @@ }else{

case '"':
if(s === S_EQ){//equal
if(s === S_EQ || s === S_ATTR //|| s == S_ATTR_SPACE
){//equal
if(s === S_ATTR){
errorHandler.warning('attribute value must after "="')
attrName = source.slice(start,p)
}
start = p+1;

@@ -223,3 +257,3 @@ p = source.indexOf(c,start)

el.add(attrName,value,start-1);
s = S_E;
s = S_ATTR_END;
}else{

@@ -229,3 +263,3 @@ //fatalError: no end quot match

}
}else if(s == S_V){
}else if(s == S_ATTR_NOQUOT_VALUE){
value = source.slice(start,p).replace(/&#?\w+;/g,entityReplacer);

@@ -237,3 +271,3 @@ //console.log(attrName,value,start,p)

start = p+1;
s = S_E
s = S_ATTR_END
}else{

@@ -248,10 +282,10 @@ //fatalError: no equal before

el.setTagName(source.slice(start,p));
case S_E:
case S_S:
case S_C:
s = S_C;
case S_ATTR_END:
case S_TAG_SPACE:
case S_TAG_CLOSE:
s =S_TAG_CLOSE;
el.closed = true;
case S_V:
case S_ATTR_NOQUOT_VALUE:
case S_ATTR:
case S_ATTR_S:
case S_ATTR_SPACE:
break;

@@ -266,2 +300,6 @@ //case S_EQ:

errorHandler.error('unexpected end of input');
if(s == S_TAG){
el.setTagName(source.slice(start,p));
}
return p;
case '>':

@@ -271,7 +309,7 @@ switch(s){

el.setTagName(source.slice(start,p));
case S_E:
case S_S:
case S_C:
case S_ATTR_END:
case S_TAG_SPACE:
case S_TAG_CLOSE:
break;//normal
case S_V://Compatible state
case S_ATTR_NOQUOT_VALUE://Compatible state
case S_ATTR:

@@ -283,11 +321,13 @@ value = source.slice(start,p);

}
case S_ATTR_S:
if(s === S_ATTR_S){
case S_ATTR_SPACE:
if(s === S_ATTR_SPACE){
value = attrName;
}
if(s == S_V){
if(s == S_ATTR_NOQUOT_VALUE){
errorHandler.warning('attribute "'+value+'" missed quot(")!!');
el.add(attrName,value.replace(/&#?\w+;/g,entityReplacer),start)
}else{
errorHandler.warning('attribute "'+value+'" missed value!! "'+value+'" instead!!')
if(currentNSMap[''] !== 'http://www.w3.org/1999/xhtml' || !value.match(/^(?:disabled|checked|selected)$/i)){
errorHandler.warning('attribute "'+value+'" missed value!! "'+value+'" instead!!')
}
el.add(value,value,start)

@@ -309,31 +349,34 @@ }

el.setTagName(source.slice(start,p));//tagName
s = S_S;
s = S_TAG_SPACE;
break;
case S_ATTR:
attrName = source.slice(start,p)
s = S_ATTR_S;
s = S_ATTR_SPACE;
break;
case S_V:
case S_ATTR_NOQUOT_VALUE:
var value = source.slice(start,p).replace(/&#?\w+;/g,entityReplacer);
errorHandler.warning('attribute "'+value+'" missed quot(")!!');
el.add(attrName,value,start)
case S_E:
s = S_S;
case S_ATTR_END:
s = S_TAG_SPACE;
break;
//case S_S:
//case S_TAG_SPACE:
//case S_EQ:
//case S_ATTR_S:
//case S_ATTR_SPACE:
// void();break;
//case S_C:
//case S_TAG_CLOSE:
//ignore warning
}
}else{//not space
//S_TAG, S_ATTR, S_EQ, S_V
//S_ATTR_S, S_E, S_S, S_C
//S_TAG, S_ATTR, S_EQ, S_ATTR_NOQUOT_VALUE
//S_ATTR_SPACE, S_ATTR_END, S_TAG_SPACE, S_TAG_CLOSE
switch(s){
//case S_TAG:void();break;
//case S_ATTR:void();break;
//case S_V:void();break;
case S_ATTR_S:
errorHandler.warning('attribute "'+attrName+'" missed value!! "'+attrName+'" instead!!')
//case S_ATTR_NOQUOT_VALUE:void();break;
case S_ATTR_SPACE:
var tagName = el.tagName;
if(currentNSMap[''] !== 'http://www.w3.org/1999/xhtml' || !attrName.match(/^(?:disabled|checked|selected)$/i)){
errorHandler.warning('attribute "'+attrName+'" missed value!! "'+attrName+'" instead2!!')
}
el.add(attrName,attrName,start);

@@ -343,5 +386,5 @@ start = p;

break;
case S_E:
case S_ATTR_END:
errorHandler.warning('attribute space is required"'+attrName+'"!!')
case S_S:
case S_TAG_SPACE:
s = S_ATTR;

@@ -351,10 +394,11 @@ start = p;

case S_EQ:
s = S_V;
s = S_ATTR_NOQUOT_VALUE;
start = p;
break;
case S_C:
case S_TAG_CLOSE:
throw new Error("elements closed character '/' and '>' must be connected to");
}
}
}
}//end outer switch
//console.log('p++',p)
p++;

@@ -364,8 +408,8 @@ }

/**
* @return end of the elementStartPart(end of elementEndPart for selfClosed el)
* @return true if has new namespace define
*/
function appendElement(el,domBuilder,parseStack){
function appendElement(el,domBuilder,currentNSMap){
var tagName = el.tagName;
var localNSMap = null;
var currentNSMap = parseStack[parseStack.length-1].currentNSMap;
//var currentNSMap = parseStack[parseStack.length-1].currentNSMap;
var i = el.length;

@@ -409,3 +453,3 @@ while(i--){

}if(prefix !== 'xmlns'){
a.uri = currentNSMap[prefix]
a.uri = currentNSMap[prefix || '']

@@ -439,3 +483,4 @@ //{console.log('###'+a.qName,domBuilder.locator.systemId+'',currentNSMap,a.uri)}

el.localNSMap = localNSMap;
parseStack.push(el);
//parseStack.push(el);
return true;
}

@@ -470,3 +515,7 @@ }

//console.log(tagName)
pos = closeMap[tagName] = source.lastIndexOf('</'+tagName+'>')
pos = source.lastIndexOf('</'+tagName+'>')
if(pos<elStartEnd){//忘记闭合
pos = source.lastIndexOf('</'+tagName)
}
closeMap[tagName] =pos
}

@@ -562,3 +611,3 @@ return pos<elStartEnd;

getLocalName:function(i){return this[i].localName},
getOffset:function(i){return this[i].offset},
getLocator:function(i){return this[i].locator},
getQName:function(i){return this[i].qName},

@@ -610,5 +659,3 @@ getURI:function(i){return this[i].uri},

if(typeof require == 'function'){
exports.XMLReader = XMLReader;
}
exports.XMLReader = XMLReader;
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc