@@ -163,21 +163,25 @@ function Animate( elem, animtype, params )
163163 }
164164}
165165
166- function ShowHideTranslate ( id , xd , yd )
166+ function ShowHideTranslate ( idorobj , xd , yd )
167167{
168168var obj , svgdoc ;
169169
170170xd = xd || 0 ;
171171yd = yd || 0 ;
172172
173- svgdoc = document . getElementById ( "svgdiv" ) . children [ 0 ] ;
173+ svgdoc = document . getElementById ( "svgdiv" ) . firstElementChild ;
174174
175175if ( svgdoc === null )
176176 {
177177 return ;
178178 }
179179
180- obj = svgdoc . getElementById ( id ) ;
180+ if ( typeof idorobj === "object" )
181+ obj = idorobj ;
182+ else
183+ obj = svgdoc . getElementById ( idorobj ) ;
184+
181185if ( obj === null )
182186 {
183187 return ;
@@ -624,11 +628,14 @@ acrescentaPontoLista : function( tag )
624628{
625629tag = tag . trim ( ) ;
626630
631+ if ( tag . indexOf ( '#' ) === 0 || tag . indexOf ( '%' ) === 0 || tag == "" )
632+ return 0 ;
633+
627634/*
628635if ( tag.indexOf('ALM') === 0 ||
629636 tag.indexOf('TMP') === 0 )
630637 {
631- tag = tag.substr( 3 );
638+ tag = tag.substr( 3 ).trim() ;
632639 }
633640else
634641*/
@@ -639,20 +646,20 @@ if ( tag.indexOf('!ALM') === 0 ||
639646 tag . indexOf ( '!TAG' ) === 0 ||
640647 tag . indexOf ( '!DCR' ) === 0 )
641648 {
642- tag = tag . substr ( 4 ) ;
649+ tag = tag . substr ( 4 ) . trim ( ) ;
643650 }
644651else
645652if ( tag . indexOf ( '!SLIM' ) === 0 ||
646653 tag . indexOf ( '!ILIM' ) === 0 ||
647654 tag . indexOf ( '!STON' ) === 0 )
648655 {
649- tag = tag . substr ( 5 ) ;
656+ tag = tag . substr ( 5 ) . trim ( ) ;
650657 }
651658else
652659if ( tag . indexOf ( '!STOFF' ) === 0 ||
653660 tag . indexOf ( '!STVAL' ) === 0 )
654661 {
655- tag = tag . substr ( 6 ) ;
662+ tag = tag . substr ( 6 ) . trim ( ) ;
656663 }
657664
658665if ( isNaN ( parseInt ( tag ) ) )
@@ -663,13 +670,8 @@ if ( isNaN( parseInt(tag) ) )
663670 }
664671 else
665672 {
666- var code = tag . charCodeAt ( 0 ) ;
667- if ( ( ( code >= 65 ) && ( code <= 90 ) ) || ( ( code >= 97 ) && ( code <= 122 ) ) )
668- {
669- // it is a letter: ok it can be a id
670- }
671- else
672- return 0 ; // it can't be an id
673+ if ( tag . indexOf ( '!' ) === 0 ) // must not begin with a '!' or '#'
674+ return 0 ;
673675 }
674676 }
675677
@@ -1508,7 +1510,7 @@ valorTagueado: function ( tag, obj )
15081510 t = NPTS [ t ] ;
15091511 if ( typeof ( TAGS [ t ] ) === 'undefined' )
15101512 {
1511- return 0 ;
1513+ return "" ;
15121514 }
15131515 return TAGS [ t ] ;
15141516 }
@@ -1520,7 +1522,7 @@ valorTagueado: function ( tag, obj )
15201522 t = NPTS [ t ] ;
15211523 if ( typeof ( DCRS [ t ] ) === 'undefined' )
15221524 {
1523- return 0 ;
1525+ return "" ;
15241526 }
15251527 return DCRS [ t ] ;
15261528 }
@@ -1566,11 +1568,11 @@ valorTagueado: function ( tag, obj )
15661568 }
15671569 if ( ( f & 0x03 ) === 0x00 )
15681570 {
1569- return WebSAGE . g_retnok ;
1571+ return "" ;
15701572 }
15711573 if ( ( f & 0x03 ) === 0x03 )
15721574 {
1573- return WebSAGE . g_retnok ;
1575+ return "" ;
15741576 }
15751577 }
15761578
@@ -2159,7 +2161,13 @@ if ( typeof( inksage_labeltxt ) != 'undefined' )
21592161 case "#exec" : // exec a script one time
21602162 try
21612163 {
2162- eval ( 'var thisobj=window.SVGDoc.getElementById("' + item . id + '"); ' + inksage_labelvec [ lbv ] . src ) ;
2164+ function evalprot ( src )
2165+ {
2166+ // create a context to protect some vars from being changed by the eval code
2167+ var lbv = null ;
2168+ return eval ( src ) ;
2169+ }
2170+ evalprot ( 'var thisobj=document.getElementById("' + item . id + '"); ' + inksage_labelvec [ lbv ] . src ) ;
21632171 }
21642172 catch ( err )
21652173 {
@@ -2893,7 +2901,13 @@ var mudou_dig = WebSAGE.g_sha1ant_dig=='' || WebSAGE.g_sha1ant_dig!=Sha1Dig;
28932901 case "#exec_on_update" : // exec a script every time data changed
28942902 try
28952903 {
2896- eval ( 'var thisobj=window.SVGDoc.getElementById("' + WebSAGE . InkSage [ i ] . parent . id + '"); ' + WebSAGE . InkSage [ i ] . src ) ;
2904+ function evalprot ( src )
2905+ {
2906+ // create a context to protect some vars from being changed by the eval code
2907+ var i , j , val , vt , mudou_dig , mudou_ana = null ;
2908+ return eval ( src ) ;
2909+ }
2910+ evalprot ( 'var thisobj=document.getElementById("' + WebSAGE . InkSage [ i ] . parent . id + '"); ' + WebSAGE . InkSage [ i ] . src ) ;
28972911 }
28982912 catch ( err )
28992913 {
@@ -3206,7 +3220,15 @@ var mudou_dig = WebSAGE.g_sha1ant_dig=='' || WebSAGE.g_sha1ant_dig!=Sha1Dig;
32063220 WebSAGE . InkSage [ i ] . parent . style . stroke = WebSAGE . InkSage [ i ] . initstroke ;
32073221 try
32083222 {
3209- eval ( 'var thisobj=window.SVGDoc.getElementById("' + WebSAGE . InkSage [ i ] . parent . id + '"); ' + script ) ;
3223+ function evalprot ( src , iloop )
3224+ {
3225+ // create a context to protect some vars from being changed by the eval code
3226+ var i = iloop ;
3227+ var j , val , vt , mudou_dig , mudou_ana = null ;
3228+ var script , ch , fill , stroke , attrib , attribval , tag = null ;
3229+ return eval ( src ) ;
3230+ }
3231+ evalprot ( 'var thisobj=window.SVGDoc.getElementById("' + WebSAGE . InkSage [ i ] . parent . id + '"); ' + script , i ) ;
32103232 }
32113233 catch ( err )
32123234 {
@@ -3315,7 +3337,14 @@ var mudou_dig = WebSAGE.g_sha1ant_dig=='' || WebSAGE.g_sha1ant_dig!=Sha1Dig;
33153337 }
33163338 if ( pini !== - 1 )
33173339 {
3318- ev = eval ( tc . substring ( pini + 5 , pend ) ) ;
3340+ function evalprot ( src )
3341+ {
3342+ // create a context to protect some vars from being changed by the eval code
3343+ var i , j , val , vt , mudou_dig , mudou_ana = null ;
3344+ var pini , pend , ev , tc = null ;
3345+ return eval ( src ) ;
3346+ }
3347+ ev = evalprot ( tc . substring ( pini + 5 , pend ) ) ;
33193348 if ( Number ( ev ) !== NaN )
33203349 {
33213350 ev = printf ( "%1.3f" , ev ) ;
0 commit comments