Python CGI script rejects data that includes data URI (403)
<p>I have a webapp that creates small images using SVG and I want it to be able to save these images to the server and then load them again (as innerHTML of a SVG element). Using ajax, I send the svg's inner HTML to my server side Python script, which looks more or less like this:</p>

<pre><code>#!/usr/bin/python
import cgi

data=cgi.FieldStorage()
filename=data.getfirst('filename')
svg=data.getfirst('svg')

f = open('/filepath/'+filename,'w')
f.write(svg)
f.close()
</code></pre>

<p>The ajax call looks like this:</p>

<pre><code>function savetoserver() {
    var filename=$('#savename').val()
    var svg = document.getElementById("svg_element").innerHTML

    dictionary={'svg':svg,'filename':filename}

    $.ajax({
        url:'http://myserver.com/savetoserver.py',
        type: 'post',
        datatype: 'html',
        data: dictionary,
        success: function(response){
            closedialog()
        }
    })
}
</code></pre>

<p>This all works great for simple inputs. However, if my SVG has a data URI of any sort in it, it fails, and the script returns 403 (forbidden). Unfortunately, I kinda want to pass it data URIs. In some cases a small image is placed inside the SVG and in almost all cases there are fonts embedded in the SVG as base64 data URIs.</p>

<p>From what little I can find out from Googling, it seems like this is a security issue, to prevent attacks on the server via data URI. Is there a standard alternative available to me that will allow me to store this data and not upset Python/Apache/whoever is being upset?</p>