Skip to content

Commit a7a562c

Browse files
dmethvinkswedberg
authored andcommitted
parseHTML: Add security warning, closes gh-59
1 parent 41b58ab commit a7a562c

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

entries/jQuery.parseHTML.xml

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
<longdesc>
1818
<p><code>jQuery.parseHTML</code> uses a native DOM element creation function to convert the string to a set of DOM elements, which can then be inserted into the document.</p>
1919
<p>By default, the <code>context</code> is the current <code>document</code> if not specified or given as <code>null</code> or <code>undefined</code>. If the HTML was to be used in another document such as an iframe, that frame's document could be used.</p>
20+
<h2>Security Considerations</h2>
21+
<p>Most jQuery APIs that accept HTML strings will run scripts that are included in the HTML. <code>jQuery.parseHTML</code> does not run script in the parsed HTML unless <code>keepScripts</code> is explicitly <code>true</code>. However, it is still possible in most environments to execute script indirectly, for example via the <code>&lt;img onerror&gt;</code> attribute. The caller should be aware of this and guard against it by cleaning or escaping any untrusted inputs from sources such as the URL or cookies. For future compatibility, callers should not depend on the ability to run <em>any</em> script content when <code>keepScripts</code> is unspecified or <code>false</code>.</p>
2022
</longdesc>
2123
<example>
2224
<desc>Create an array of Dom nodes using an HTML string and insert it into a div.</desc>

0 commit comments

Comments
 (0)