MCPcopy
hub / github.com/jquerytools/jquerytools / xml

Function xml

lib/jslint.js:216–260  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

214return w;}
215function closetag(n){return'</'+n+'>';}
216function xml(){var a,e,n,q,t,url,wmode;xmode='xml';stack=null;for(;;){switch(nexttoken.value){case'<':if(!stack){stack=[];}
217advance('<');t=nexttoken;n=xmlword(true);t.name=n;if(!xtype){if(option.adsafe&&(!option.fragment||n!=='div')){error("ADsafe violation: Wrap the widget in a div.",token);}
218if(xmltype[n]){xmltype[n].doBegin();n=xtype;e=false;}else{if(option.fragment){xmltype.html.doBegin();}else{error("Unrecognized tag '<{a}>'.",nexttoken,n);}}}else{if(stack.length===0){error("What the hell is this?");}
219e=xmltype[xtype].doTagName(n,stack[stack.length-1].name);}
220t.type=n;for(;;){if(nexttoken.id==='/'){advance('/');if(nexttoken.id!=='>'){warning("Expected '{a}' and instead saw '{b}'.",nexttoken,'>',nexttoken.value);}
221e=true;break;}
222if(nexttoken.id&&nexttoken.id.substr(0,1)==='>'){break;}
223a=xmlword();switch(xmltype[xtype].doAttribute(n,a)){case'script':xmode='string';advance('=');q=nexttoken.id;if(q!=='"'&&q!=="'"){error("Missing quote.");}
224xmode=q;wmode=option.white;option.white=false;advance(q);statements('on');option.white=wmode;if(nexttoken.id!==q){error("Missing close quote on script attribute.");}
225xmode='xml';advance(q);break;case'value':advance('=');if(!nexttoken.identifier&&nexttoken.type!=='(string)'&&nexttoken.type!=='(number)'){error("Bad value '{a}'.",nexttoken,nexttoken.value);}
226advance();break;case'id':advance('=');if(nexttoken.type!=='(string)'||!nexttoken.value){warning("Bad id '{a}'.",nexttoken,nexttoken.value);}
227t.id=nexttoken.value.toLowerCase();if(ids[t.id]===true){warning("Duplicate id='{a}'.",nexttoken,nexttoken.value);}else if(option.adsafe){if((adsafe_id||stack.level>1)){warning("ADsafe violation: A widget can have only one id.",nexttoken);}else{adsafe_id=t.id;if(!/^[a-z][a-z0-9]*$/.test(adsafe_id)){warning("ADSAFE violation: bad id.",t);}}}
228ids[t.id]=true;advance();break;case'name':advance('=');if(nexttoken.type!=='(string)'||!nexttoken.value||nexttoken.value===adsafe_id){warning("Bad name attribute.",nexttoken);}
229advance();break;case'string':advance('=');if(nexttoken.type!=='(string)'){error("Bad value '{a}'.",nexttoken,nexttoken.value);}
230advance();break;case'href':advance('=');if(nexttoken.type!=='(string)'){error("Bad value '{a}'.",nexttoken,nexttoken.value);}
231if(option.adsafe&&ux.test(nexttoken.value)){error("ADsafe URL violation.");}
232url=nexttoken.value;urls.push(url);advance();break;case'dangerous':advance('=');if(nexttoken.type!=='(string)'){error("Bad value '{a}'.",nexttoken,nexttoken.value);}
233if(option.adsafe&&ux.test(nexttoken.value)){error("ADsafe URL violation.");}
234advance();break;case'define':advance('=');if(nexttoken.type!=='(string)'){error("Bad value '{a}'.",nexttoken,nexttoken.value);}
235addlabel(nexttoken.value,'var');advance();break;default:if(nexttoken.id==='='){advance('=');if(!nexttoken.identifier&&nexttoken.type!=='(string)'&&nexttoken.type!=='(number)'){error("Bad value '{a}'.",nexttoken,nexttoken.value);}
236advance();}}}
237switch(xmltype[xtype].doIt(n)){case'script':xmode='script';advance('>');indent=nexttoken.from;if(src){if(option.adsafe&&(!adsafe_may||!approved[url])){error("ADsafe script violation.",token);}}else{if(adsafe_went){error("ADsafe script violation.",token);}
238statements('script');}
239if(nexttoken.id!=='</'&&nexttoken.id!=='(end)'){warning("Expected '{a}' and instead saw '{b}'.",nexttoken,'<\/script>',nexttoken.value);}
240xmode='xml';break;case'special':e=true;n=closetag(t.name);if(!lex.skip(n)){error("Missing '{a}'.",t,n);}
241break;default:lex.skip('>');}
242if(option.adsafe&&stack.length===0&&!adsafe_id){warning("ADSAFE violation: missing id.",t);}
243if(!e){stack.push(t);}
244break;case'</':advance('</');n=xmlword(true);t=stack.pop();if(!t){error("Unexpected '{a}'.",nexttoken,closetag(n));}
245if(t.name!==n){error("Expected '{a}' and instead saw '{b}'.",nexttoken,closetag(t.name),closetag(n));}
246if(nexttoken.id!=='>'){error("Missing '{a}'.",nexttoken,'>');}
247if(stack.length>0){lex.skip('>');}else{advance('>');}
248break;case'<!':if(option.adsafe){error("ADsafe HTML violation.");}
249for(;;){advance();if(nexttoken.id==='>'){break;}
250if(nexttoken.id==='<'||nexttoken.id==='(end)'){error("Missing '{a}'.",token,'>');}}
251lex.skip('>');break;case'<!--':if(option.adsafe){error("ADsafe comment violation.");}
252lex.skip('-->');break;case'<%':if(option.adsafe){error("ADsafe HTML violation.");}
253lex.skip('%>');break;case'<?':if(option.adsafe){error("ADsafe HTML violation.");}
254for(;;){advance();if(nexttoken.id==='?>'){break;}
255if(nexttoken.id==='<?'||nexttoken.id==='<'||nexttoken.id==='>'||nexttoken.id==='(end)'){error("Missing '{a}'.",token,'?>');}}
256lex.skip('?>');break;case'<=':case'<<':case'<<=':error("Missing '{a}'.",nexttoken,'&lt;');break;case'(end)':return;}
257if(stack&&stack.length===0){return;}
258if(!lex.skip('')){if(!stack){error("Bad XML.");}
259t=stack.pop();if(t.value){error("Missing '{a}'.",t,closetag(t.name));}else{return;}}
260advance();}}
261type('(number)',idValue);type('(string)',idValue);syntax['(identifier)']={type:'(identifier)',lbp:0,identifier:true,nud:function(){var v=this.value,s=scope[v];if(s&&(s===funct||s===funct['(global)'])){if(!funct['(global)']){switch(funct[v]){case'unused':funct[v]='var';break;case'label':warning("'{a}' is a statement label.",token,v);break;}}}else if(funct['(global)']){if(option.undef){warning("'{a}' is undefined.",token,v);}
262note_implied(token);}else{switch(funct[v]){case'closure':case'function':case'var':case'unused':warning("'{a}' used out of scope.",token,v);break;case'label':warning("'{a}' is a statement label.",token,v);break;case'outer':case true:break;default:if(s===true){funct[v]=true;}else if(typeof s!=='object'){if(option.undef){warning("'{a}' is undefined.",token,v);}else{funct[v]=true;}
263note_implied(token);}else{switch(s[v]){case'function':case'var':case'unused':s[v]='closure';funct[v]='outer';break;case'closure':case'parameter':funct[v]='outer';break;case'label':warning("'{a}' is a statement label.",token,v);}}}}

Callers 1

itselfFunction · 0.85

Calls 7

advanceFunction · 0.85
xmlwordFunction · 0.85
errorFunction · 0.85
warningFunction · 0.85
statementsFunction · 0.85
addlabelFunction · 0.85
closetagFunction · 0.85

Tested by

no test coverage detected