Hi,
I have users pasting content into a radEditor in a content management system. Unfortunately the tools they are pasting from have some funny ideas about what constitutes valid HTML.
In one case, the user pasted this:
You will notice that there is an <li> tag inside a <span> inside another <li> tag.
<understatement> This caused a problem. </understatement>
After this content had been saved to the database, the UpdatePanel where it was displayed could no longer successfully execute postbacks. Attempts to save the object hosting this content via a button in the panel consistently threw a JSON serialization error (Invalid JSON Primitive: .) From what I can gather, the updatePanel tried to package this invalid content up as part of its AJAX request, and the deserializer on the server blew up when presented with it. After removing the offending markup (extra <li>) in the database, the panel returned to normal operation and save attempts succeeded.
So, my question is, how can I validate user-pasted garbage to ensure that the JSON deserializer will be able to handle it? Is there an option on the editor or a recommended approach? And, when encountering invalid pasted content, is there a way to strip the offending markup?
Thanks in advance,
Jordan
I have users pasting content into a radEditor in a content management system. Unfortunately the tools they are pasting from have some funny ideas about what constitutes valid HTML.
In one case, the user pasted this:
<ul> |
<li> |
<div style="text-align: left;"> |
BLAH BLAH BLAH BLAH<span style="font-family: arial; font-size: 10px;">6 |
<div> |
</div> |
<li> |
<div style="text-align: left;"> |
</div> |
</li> |
</span> |
</div> |
</li> |
</ul> |
You will notice that there is an <li> tag inside a <span> inside another <li> tag.
<understatement> This caused a problem. </understatement>
After this content had been saved to the database, the UpdatePanel where it was displayed could no longer successfully execute postbacks. Attempts to save the object hosting this content via a button in the panel consistently threw a JSON serialization error (Invalid JSON Primitive: .) From what I can gather, the updatePanel tried to package this invalid content up as part of its AJAX request, and the deserializer on the server blew up when presented with it. After removing the offending markup (extra <li>) in the database, the panel returned to normal operation and save attempts succeeded.
So, my question is, how can I validate user-pasted garbage to ensure that the JSON deserializer will be able to handle it? Is there an option on the editor or a recommended approach? And, when encountering invalid pasted content, is there a way to strip the offending markup?
Thanks in advance,
Jordan