Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If you want to block bad scripts from WMD on the client side, take a look at my answer here: <a href="https://stackoverflow.com/questions/2837593/align-wmd-editors-preview-html-with-server-side-html-validation-e-g-no-embedde">Align the WMD editor&#39;s preview HTML with server-side HTML validation (e.g. no embedded JavaScript code)</a>. </p> <p>It shows how to implement a client-side whitelist in the WMD editor to restrict WMD's preview pane HTML to known-safe HTML elements and known-safe HTML attributes. It does the validation <em>after</em> WMD geneates its HTML, so even if there's a bug in the WMD editor's HTML generation which allows bad script to get through, the whitelist blocker will catch it. This code is based on StackOverflow.com's implementation of the same validation.</p> <p>That said, you also need server-side validation too (If you're using PHP, <a href="http://htmlpurifier.org/" rel="nofollow noreferrer">HTML Purifier</a> is a good choice), because even if you fix the client, that doesn't prevent an attacker from simulating a browser and saving malicious markdown by POST-ing it to your server. So doing client-side WMD previewer validation isn't actually required, except to defend against an obscure case where an attacker manages to get compromised markdown onto the server, and convinces a site moderator to edit the page. In that case, client WMD previewer validation might prevent an attacker from taking over the entire site. </p> <p>Also, doing client-side validation can be helpful because then you know that the same tags and HTML allowed by the client will also be allowed on the server. Make sure to sync the server-side whitelist with the client whitelist. StackOverflow's whitelist is <a href="https://meta.stackexchange.com/questions/1777/what-html-tags-are-allowed-on-stack-overflow-server-fault-and-super-user">here</a> if you want an example.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload