<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en-us" xmlns="http://www.w3.org/2005/Atom"><title>Simon Willison's Weblog: validation</title><link href="http://simonwillison.net/" rel="alternate"/><link href="http://simonwillison.net/tags/validation.atom" rel="self"/><id>http://simonwillison.net/</id><updated>2009-08-12T16:59:57+00:00</updated><author><name>Simon Willison</name></author><entry><title>minixsv</title><link href="https://simonwillison.net/2009/Aug/12/minixsv/#atom-tag" rel="alternate"/><published>2009-08-12T16:59:57+00:00</published><updated>2009-08-12T16:59:57+00:00</updated><id>https://simonwillison.net/2009/Aug/12/minixsv/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="http://www.familieleuthe.de/DownloadMiniXsv.html"&gt;minixsv&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
As far as I can tell, this is the only library that can validate XML using pure Python (no C extension required). I’d be extremely happy if someone would write a pure Python library (or one that only depends on ElementTree, which is included in the standard library) for validating XML against a Relax NG Compact syntax schema. Even DTD validation would be better than nothing!

    &lt;p&gt;&lt;small&gt;&lt;/small&gt;Via &lt;a href="http://stackoverflow.com/questions/1243449/validating-xml-in-python-without-non-python-dependencies"&gt;Stack Overflow&lt;/a&gt;&lt;/small&gt;&lt;/p&gt;


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/elementtree"&gt;elementtree&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/minixsv"&gt;minixsv&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/python"&gt;python&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/relaxng"&gt;relaxng&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/validation"&gt;validation&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/xml"&gt;xml&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/xmlschema"&gt;xmlschema&lt;/a&gt;&lt;/p&gt;



</summary><category term="elementtree"/><category term="minixsv"/><category term="python"/><category term="relaxng"/><category term="validation"/><category term="xml"/><category term="xmlschema"/></entry><entry><title>Evil GIFs: Partial Same Origin Bypass with Hybrid Files</title><link href="https://simonwillison.net/2008/Jul/1/evil/#atom-tag" rel="alternate"/><published>2008-07-01T08:58:45+00:00</published><updated>2008-07-01T08:58:45+00:00</updated><id>https://simonwillison.net/2008/Jul/1/evil/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="http://radar.oreilly.com/archives/2008/06/partial-same-origin-bypass-wit.html"&gt;Evil GIFs: Partial Same Origin Bypass with Hybrid Files&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
First there were PNGs that had crossdomain.xml files embedded in them, now there are GIFs that contain Java applets (as JAR files). At this point I’d say don’t even bother trying to validate uploaded files, just make sure they’re served off an entirely different domain instead where XSS doesn’t matter.


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/applets"&gt;applets&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/crossdomainxml"&gt;crossdomainxml&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/gifs"&gt;gifs&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/javaapplets"&gt;javaapplets&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/pngs"&gt;pngs&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/security"&gt;security&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/uploads"&gt;uploads&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/validation"&gt;validation&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/xss"&gt;xss&lt;/a&gt;&lt;/p&gt;



</summary><category term="applets"/><category term="crossdomainxml"/><category term="gifs"/><category term="javaapplets"/><category term="pngs"/><category term="security"/><category term="uploads"/><category term="validation"/><category term="xss"/></entry><entry><title>Quoting Mark Pilgrim</title><link href="https://simonwillison.net/2008/Mar/10/draconian/#atom-tag" rel="alternate"/><published>2008-03-10T14:01:28+00:00</published><updated>2008-03-10T14:01:28+00:00</updated><id>https://simonwillison.net/2008/Mar/10/draconian/#atom-tag</id><summary type="html">
    &lt;blockquote cite="http://diveintomark.org/archives/2008/03/09/no-fury-like-dracon-scorned"&gt;&lt;p&gt;For the record, my site is valid HTML 5, except the parts that aren't. My therapist says I shouldn't rely so much on external validation.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p class="cite"&gt;&amp;mdash; &lt;a href="http://diveintomark.org/archives/2008/03/09/no-fury-like-dracon-scorned"&gt;Mark Pilgrim&lt;/a&gt;&lt;/p&gt;

    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/html5"&gt;html5&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/mark-pilgrim"&gt;mark-pilgrim&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/standards"&gt;standards&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/validation"&gt;validation&lt;/a&gt;&lt;/p&gt;



</summary><category term="html5"/><category term="mark-pilgrim"/><category term="standards"/><category term="validation"/></entry><entry><title>JavaScript: It's Just Not Validation!</title><link href="https://simonwillison.net/2008/Jan/1/javascript/#atom-tag" rel="alternate"/><published>2008-01-01T12:07:30+00:00</published><updated>2008-01-01T12:07:30+00:00</updated><id>https://simonwillison.net/2008/Jan/1/javascript/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="http://www.sitepoint.com/article/javascript-just-not-validation"&gt;JavaScript: It&amp;#x27;s Just Not Validation!&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
I like the explanation of JavaScript as offering input assistance rather than validation.


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/inputassistance"&gt;inputassistance&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/javascript"&gt;javascript&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/sitepoint"&gt;sitepoint&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/validation"&gt;validation&lt;/a&gt;&lt;/p&gt;



</summary><category term="inputassistance"/><category term="javascript"/><category term="sitepoint"/><category term="validation"/></entry><entry><title>jQuery plugin: Validation</title><link href="https://simonwillison.net/2007/Jun/30/bassistancede/#atom-tag" rel="alternate"/><published>2007-06-30T22:26:07+00:00</published><updated>2007-06-30T22:26:07+00:00</updated><id>https://simonwillison.net/2007/Jun/30/bassistancede/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="http://bassistance.de/jquery-plugins/jquery-plugin-validation/"&gt;jQuery plugin: Validation&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
Pretty clever way of attacking the client-side form validation problem; supports both configuration object literals and custom attributes on the form fields themselves.


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/javascript"&gt;javascript&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/jquery"&gt;jquery&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/plugins"&gt;plugins&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/validation"&gt;validation&lt;/a&gt;&lt;/p&gt;



</summary><category term="javascript"/><category term="jquery"/><category term="plugins"/><category term="validation"/></entry><entry><title>Keep your JSON valid</title><link href="https://simonwillison.net/2006/Oct/11/json/#atom-tag" rel="alternate"/><published>2006-10-11T14:44:03+00:00</published><updated>2006-10-11T14:44:03+00:00</updated><id>https://simonwillison.net/2006/Oct/11/json/#atom-tag</id><summary type="html">
    &lt;p id="p-0"&gt;I'm a big fan of &lt;a href="http://www.json.org/"&gt;JSON&lt;/a&gt;, and it's great to see it turning up as an output option for so many Web APIs. Unfortunately, many of these APIs are getting the details slightly wrong and in doing so are producing invalid JSON.&lt;/p&gt;

&lt;p id="p-1"&gt;JSON isn't just the object-literal syntax of JavaScript; it's a very tightly defined subset of that syntax. The site has a spec (illustrated with pretty state machine diagrams) and there's &lt;a href="http://www.ietf.org/rfc/rfc4627.txt" title="RFC 4627"&gt;an RFC&lt;/a&gt; as well.&lt;/p&gt;

&lt;p id="p-2"&gt;By far the most common error I've encountered relates to object keys. In JSON (unlike in JavaScript) these MUST be double-quoted strings. In fact, ALL strings in JSON must be enclosed in double quotes (JavaScript also allows single quotes; JSON does not).&lt;/p&gt;

&lt;p id="p-3"&gt;Valid:&lt;/p&gt;

&lt;pre&gt;&lt;code class="json"&gt;{ "name": "Simon" }&lt;/code&gt;&lt;/pre&gt;

&lt;p id="p-4"&gt;Invalid:&lt;/p&gt;

&lt;pre&gt;&lt;code class="invalid-json"&gt;{ name: "Simon" }
{ 'name': "Simon" }
{ "name": 'Simon' }&lt;/code&gt;&lt;/pre&gt;

&lt;p id="p-5"&gt;It's worth reviewing the other key differences between JSON and JavaScript. Remember, all valid JSON is valid JavaScript but the opposite is not true; JSON is a subset.&lt;/p&gt;

&lt;p id="p-6"&gt;This stuff matters. Python's excellent &lt;a href="http://cheeseshop.python.org/pypi/simplejson"&gt;simplejson&lt;/a&gt; module is a strict parser; it refuses to consume invalid JSON. If you're building a JSON API it's worth taking the time to ensure you are valid - I suggest installing Python and simplejson and trying the following:&lt;/p&gt;

&lt;pre&gt;&lt;code class="shell"&gt;$ python
Python 2.5 (r25:51918, Sep 19 2006, 08:49:13) 
[GCC 4.0.1 (Apple Computer, Inc. build 5341)] on darwin
&amp;gt;&amp;gt;&amp;gt; import urllib, simplejson
&amp;gt;&amp;gt;&amp;gt; url = "http://your-api.org/your-api/json"
&amp;gt;&amp;gt;&amp;gt; simplejson.load(urllib.urlopen(url))&lt;/code&gt;&lt;/pre&gt;

&lt;p id="p-7"&gt;Try it against a few JSON supporting sites. You might be surprised at the amount of invalid JSON out there.&lt;/p&gt;

&lt;p id="p-8"&gt;As with outputting XML, the best way to avoid these problems is to use a pre-existing JSON generation library rather than rolling your own. I've had good experiences with &lt;a href="http://cheeseshop.python.org/pypi/simplejson"&gt;simplejson&lt;/a&gt; for Python and &lt;a href="http://www.aurore.net/projects/php-json/"&gt;php-json&lt;/a&gt; for PHP.&lt;/p&gt;
    
        &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/json"&gt;json&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/validation"&gt;validation&lt;/a&gt;&lt;/p&gt;
    

</summary><category term="json"/><category term="validation"/></entry></feed>