Skip to content

Commit 6d102a5

Browse files
ncb000gtrobrighter
authored andcommitted
Fixed a problem with substring. Calling it on an object rather than a string. Call toString to make sure it's a string.
Signed-off-by: Nick Campbell <nicholas.j.campbell@gmail.com>
1 parent 14a133f commit 6d102a5

File tree

1 file changed

+34
-34
lines changed

1 file changed

+34
-34
lines changed

lib/node-xml.js

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
// An xml parser for node.js
33
// (C) Rob Righter (@robrighter) 2009 - 2010, Licensed under the MIT-LICENSE
44
// Contributions from David Joham
5-
65

7-
(function () {
6+
7+
(function () {
88

99
// CONSTANTS
1010
var whitespace = "\n\r\t ";
@@ -86,7 +86,7 @@ XMLP._errs[XMLP.ERR_ELM_NESTING = 17] = "Element: must be nested correctly";
8686

8787

8888
XMLP.prototype.continueParsing = function(strXML) {
89-
89+
9090
if(this.m_chunkTransitionContinuation){
9191
strXML = this.m_chunkTransitionContinuation + strXML;
9292
}
@@ -153,7 +153,7 @@ XMLP.prototype._checkStructure = function(iEvent) {
153153

154154
return iEvent;
155155

156-
}
156+
}
157157

158158
XMLP.prototype._clearAttributes = function() {
159159
this.m_atts = new Array();
@@ -255,7 +255,7 @@ XMLP.prototype._parse = function() {
255255
else{
256256
return this._parseText (this.m_iP);
257257
}
258-
258+
259259

260260
}
261261

@@ -297,15 +297,15 @@ XMLP.prototype._getContextualNamespace = function (prefix){
297297
}
298298
}
299299
}
300-
300+
301301
//no match was found for the prefix so pop off the first non-prefix namespace
302302
for(var i = (this.m_namespaceList.length-1); i>= 0; i--){
303303
var item = this.m_namespaceList[i];
304304
if(item.prefix === ''){
305305
return item.uri;
306306
}
307307
}
308-
308+
309309
//still nothing, lets just return an empty string
310310
return '';
311311
}
@@ -318,9 +318,9 @@ XMLP.prototype._removeExpiredNamesapces = function (closingtagname) {
318318
keeps.push(item);
319319
}
320320
});
321-
321+
322322
this.m_namespaceList = keeps;
323-
323+
324324
}
325325

326326
////////////////////////////////////////////////////////////////////////
@@ -331,7 +331,7 @@ XMLP.prototype._parseAttribute = function(iB, iE) {
331331
var cQuote, strN, strV;
332332

333333
this.m_cAlt = ""; //resets the value so we don't use an old one by accident (see testAttribute7 in the test suite)
334-
334+
335335
iNB = SAXStrings.indexOfNonWhitespace(this.m_xml, iB, iE);
336336
if((iNB == -1) ||(iNB >= iE)) {
337337
return iNB;
@@ -671,16 +671,16 @@ XMLP.prototype._replaceEntity = function(strD, iB, iE) {
671671
case "apos": strEnt = "'"; break;
672672
case "quot": strEnt = "\""; break;
673673
case "nbsp":strEnt = ''; break;
674-
case "lt":strEnt = '<'; break;
675-
case "gt":strEnt = '>'; break;
676-
case "amp":strEnt = '&'; break;
674+
case "lt":strEnt = '<'; break;
675+
case "gt":strEnt = '>'; break;
676+
case "amp":strEnt = '&'; break;
677677
case "cent":strEnt = "¢"; break;
678678
case "pound":strEnt = '£'; break;
679679
case "yen":strEnt = '¥'; break;
680-
case "euro":strEnt = '€'; break;
681-
case "sect":strEnt = '§'; break;
682-
case "copy":strEnt = '©'; break;
683-
case "reg":strEnt = '®'; break;
680+
case "euro":strEnt = '€'; break;
681+
case "sect":strEnt = '§'; break;
682+
case "copy":strEnt = '©'; break;
683+
case "reg":strEnt = '®'; break;
684684
default:
685685
if(strD.charAt(iB) == "#") {
686686
strEnt = String.fromCharCode(parseInt(strD.substring(iB + 1, iE)));
@@ -693,7 +693,7 @@ XMLP.prototype._replaceEntity = function(strD, iB, iE) {
693693
this._setContent(XMLP._CONT_ALT, strEnt);
694694

695695
return XMLP._ENTITY;
696-
}
696+
}
697697

698698
XMLP.prototype._setContent = function(iSrc) {
699699
var args = arguments;
@@ -709,7 +709,7 @@ XMLP.prototype._setContent = function(iSrc) {
709709
}
710710
this.m_cSrc = iSrc;
711711

712-
}
712+
}
713713

714714
XMLP.prototype._setErr = function(iErr) {
715715
var strErr = XMLP._errs[iErr];
@@ -728,11 +728,11 @@ XMLP.prototype._setErr = function(iErr) {
728728
//event-based interface for parsing. This is the object users interact with when coding
729729
//with XML for <SCRIPT>
730730
var SaxParser = function(eventhandlerfactory) {
731-
731+
732732
var eventhandler = new function(){
733-
733+
734734
}
735-
735+
736736
var thehandler = function() {};
737737
thehandler.prototype.onStartDocument = function (funct){
738738
eventhandler.onStartDocument = funct;
@@ -758,12 +758,12 @@ var SaxParser = function(eventhandlerfactory) {
758758
thehandler.prototype.onWarning = function(funct) {
759759
eventhandler.onWarning = funct;
760760
}
761-
761+
762762
thehandler.prototype.onError = function(funct) {
763763
eventhandler.onError = funct;
764764
}
765-
766-
765+
766+
767767
eventhandlerfactory(new thehandler());
768768
//eventhandler = eventhandler(eventhandler);
769769
this.m_hndDoc = eventhandler;
@@ -809,11 +809,11 @@ SaxParser.prototype.parseString = function(strD) {
809809
that.m_parser.continueParsing(strD);
810810
startnew = true;
811811
}
812-
812+
813813
//if(that.m_hndDoc && that.m_hndDoc.setDocumentLocator) {
814814
// that.m_hndDoc.setDocumentLocator(that);
815815
//}
816-
816+
817817
that.m_bErr = false;
818818

819819
if(!that.m_bErr && !startnew) {
@@ -906,8 +906,8 @@ SaxParser.prototype._fireError = function(strMsg) {
906906

907907
SaxParser.prototype._fireEvent = function(iEvt) {
908908
var hnd, func, args = arguments, iLen = args.length - 1;
909-
910-
909+
910+
911911
if(this.m_bErr) return;
912912

913913
if(SaxParser.DOC_B == iEvt) {
@@ -937,7 +937,7 @@ SaxParser.prototype._fireEvent = function(iEvt) {
937937
else if (SaxParser.CMNT == iEvt) {
938938
func = "onComment"; hnd = this.m_hndLex;
939939
}
940-
940+
941941
if(hnd && hnd[func]) {
942942
if(0 == iLen) {
943943
hnd[func]();
@@ -970,7 +970,7 @@ SaxParser.prototype._parseLoop = function(parser) {
970970
parser = this.m_parser;
971971
while(!this.m_bErr) {
972972
iEvent = parser.next();
973-
973+
974974
if(iEvent == XMLP._ELM_B) {
975975
theatts = this.m_parser.m_atts;
976976
nameobject = parser._parsePrefixAndElementName(parser.getName());
@@ -991,7 +991,7 @@ SaxParser.prototype._parseLoop = function(parser) {
991991
theattsandnamespace = parser._parseNamespacesAndAtts(theatts);
992992
var theuri = parser._getContextualNamespace(nameobject.prefix);
993993
this._fireEvent(SaxParser.ELM_B, nameobject.name, theattsandnamespace[0], (nameobject.prefix === '')? null : nameobject.prefix, (theuri === '')? null : theuri ,theattsandnamespace[1] );
994-
994+
995995
parser._removeExpiredNamesapces(parser.getName());
996996
this._fireEvent(SaxParser.ELM_E, nameobject.name, (nameobject.prefix === '')? null : nameobject.prefix, (theuri === '')? null : theuri);
997997
//this._fireEvent(SaxParser.ELM_B, parser.getName(), this.m_parser.m_atts.map(function(item){return { name : item[0], value : item[1], };}) );
@@ -1028,7 +1028,7 @@ SaxParser.prototype._parseLoop = function(parser) {
10281028
}
10291029
}
10301030

1031-
}
1031+
}
10321032

10331033
//SAXStrings: a useful object containing string manipulation functions
10341034
var SAXStrings = function() {
@@ -1121,7 +1121,7 @@ SAXStrings.replace = function(strD, iB, iE, strF, strR) {
11211121
iB = iB || 0;
11221122
iE = iE || strD.length;
11231123

1124-
return strD.substring(iB, iE).split(strF).join(strR);
1124+
return strD.toString().substring(iB, iE).split(strF).join(strR);
11251125

11261126
}
11271127

0 commit comments

Comments
 (0)