Welcome Guest, Not a member yet? Register   Sign In
XML RPC > html in response > htmlspecialchars + javascript stripping
#1

[eluser]HdotNET[/eluser]
Hi there,

Building an XMLRPC server application.

The problem I am having is that I need to send html as a response, however the response is being recieved escaped using htmlspecialchars.

ie, this:

Code:
<html>
<body>
This is some text.
<script>
var thing="blah";
</script&rt;
</body>
</html>

becomes this in the response:

EDIT: Spaces put in artificially after ampersands to prevent the browser rendering them as entities.

Code:
<?xml version="1.0" encoding="UTF-8"?>
<methodResponse>
<params>
<param>
<value>
<struct>
<member>
<name>htmloutput</name>
<value>
<string>& lt;html& gt;& lt;body& gt;This is some text.& lt;script& gt; var thing=& quot;blah& quot;;& lt;/script& gt;& lt;/body& gt;& lt;/html& gt;</string>
</value>
</member>
</struct></value>
</param>
</params>
</methodResponse>

and once the client outputs the result, the script tag has also been stripped:

Code:
& lt;html& gt;& lt;body& gt;This is some text. var thing="blah";& lt;/body& gt;& lt;/html& gt;


My testing here is using the example lifted straight form the manual:


http://ellislab.com/codeigniter/user-gui...mlrpc.html

Except the server response is formulated as follows:

Code:
$string = '&lt;html&gt;&lt;body&gt;This is some text. var thing="blah";&lt;/body&gt;&lt;/html&gt;';
        
        $response = array (
                   array(
                         'htmloutput' => array($string, 'string')
                        ),
                 'struct'
                 );

Looking through the XML-RPC code I can see that htmlspecialchars is used, while not ideal I suppose I can get round that with htmlspecialchars_decode. Or alternativley alter the library so as to allow it to send html using cdata


I haven't yet found how the tags are being removed, which is somewhere in the client library.

So my question is ...

How the hell do I send html with javascript?

Or shoudl I RTFM a bit more ;-)?
http://www.xmlrpc.com/spec


Messages In This Thread
XML RPC &gt; html in response &gt; htmlspecialchars + javascript stripping - by El Forum - 05-25-2008, 05:58 AM



Theme © iAndrew 2016 - Forum software by © MyBB