1
Vote

Escaping Single Quotes Fails

description

When the script code contains # symbols besides those used for identifying script start/stop it causes the regular expression look-ahead to produce false negatives which results in script quotes for strings being escaped as though they belonged in a push statement.
 
<script type='text/html' id='dropDownTemplate'>
 
                     <# if (results.length > 0) { #>
                            <#
                            var initial = results[0];
                            var selectedMake = $('#hiddenMakes').val();
                            var selectedModel = $('#hiddenModels').val();
                            for (var x = 0; x < results.length; x++) {
                                var item = results[x];
                                if (selectedMake == item.value) { #>
                                <option value='<#= item.value #>' selected='selected'><#= item.text #></option>
                                <# } else {#>
                                <option value='<#= item.value #>'><#= item.text #></option>
                                <# } 
                            } #>
                    <# } else { #>
                                <option value=''></option>        
                    <# } #>
                </script>

comments