Project

General

Profile

Bug #14988

Updated by Mathias Schreiber almost 10 years ago

in my extension I want to write some javascript like: 

 $content.=' 
 <script type="text/javascript"> 
 <!-- 
 function count_to(j) { 
    var s=""; 
    for (var i=0; i<j; i++ ) { 
        s+=i+"    "; 
    } 
    alert(s); 
 } 
 count_to(10); 
 //--> 
 </script>'; 


 what ends up in the HTML-source of the resulting page is: 
 <script type="text/javascript"> 
 <!-- 
 function count_to(j) { 
 var s=""; 
 for (var i=0; i<j; i="" s="i+&quot;" alertscount_to10--=""> 
 </script> 

 it seems that the cleaning is done inside of the HTML-comment. 
 Especially the '<' in the loop-header is mis-interpreted as an opening HTML-tag and anything following as parameter to this tag. 

 unsetting  
 page.config.xhtml_cleaning = all  
 leaves all javascript ok. 

 my workaround for this small part of code is using 
    for (var i=0; j>i; i++ ) { 
 instead of  
    for (var i=0; i<j; i++ ) { 

 But I think it can go worse if in the javascript a '<' is needed in a string. 

 BTW: I prepare the proper javascript-code with infos from within PHP, so I can't include the javascript from extern. 




 




 (issue imported from #M1477)

Back