Script injection affects jquery template -
i tried load string using {{ html }} in jquery template. script injection affects {{html }}. how restrict script injection.
it not problem jquery-template, because how html parses <script>
element within string literals. see why split <script> tag when writing document.write()?
if want parse , execute script, easy way move script separate file(and include file in html page) instead of inlining it.
or can escape like
testtemplate = "<i>{{html txt}}</i>"; $.template('testtemplate', testtemplate); $.tmpl("testtemplate", { txt: "<b>bold</b> , \x3cscript>alert('abc')\x3c/script>" }).appendto("#target");
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script src="http://ajax.microsoft.com/ajax/jquery.templates/beta1/jquery.tmpl.js"></script> <ul id="target"></ul>
Comments
Post a Comment