Any word on how to fix this? I am experiencing the same issue with spaces killing the script.
EDIT: FIXED
I got mine working by declaring the variable earlier then using the variable in the script:
$the_query = "{query}";
echo '<?xml version="1.0"?>
<items>
<item uid="NA" valid="no">
<title>'.strlen($the_query).'</title>
<subtitle>"'.$the_query.'"</subtitle>
<icon>D9AAD7B8-26CC-4444-B8D0-35F833CC0C05.png</icon>
</item>
</items>';