Question
· Jun 29, 2016

CSP Illegal Value error

I've created a CSP page to take in a base64 value from a <textarea> and decode it. When I run it I get the error . Any ideas?

Error: <ILLEGAL VALUE>zOnPageBODY+28^csp.decode.1

ErrorNo: 5002

Here is my code

<form method="post" action="">
<table>
<tr><td><textarea rows="40" cols="200" name="submitstring"></textarea></td></tr>
<tr><td><select name="decodeoption"><option>Decode</option><option>Encode</option></select><input type="submit"/></td></tr>
<tr><td>&nbsp;</td></tr>
<tr><td><h2>Result</h2></td></tr>
<tr><td>

<script language=Cache runat=server>
Set tString = $Get(%request.Data("submitstring",1))
Set tAction = $Get(%request.Data("decodeoption",1))
If tAction = "Decode"
{
Set tOutput = $SYSTEM.Encryption.Base64Decode(tString)
}
Else
{
Set tOutput = $SYSTEM.Encryption.Base64Encode(tString)
}
Write tOutput
</script>
</td></tr>
</table>
</form>

Discussion (12)0
Log in or sign up to continue

Based on Alexanders comment, I think this should work.

<form method="post" action="">
<table>
<tr><td><textarea rows="40" cols="200" name="submitstring"></textarea></td></tr>
<tr><td><select name="decodeoption"><option>Decode</option><option>Encode</option></select><input type="submit"/></td></tr>
<tr><td>&nbsp;</td></tr>
<tr><td><h2>Result</h2></td></tr>
<tr><td>

<script language=Cache runat=server>
Set tString = $Get(%request.Data("submitstring",1))
Set tAction = $Get(%request.Data("decodeoption",1))
If tAction = "Decode" {
    Set tString = $SYSTEM.Encryption.Base64Decode(tString)
    Set tOutput = $ZCONVERT(tString,"I","UTF8")
} Else {
    Set tString = $ZCONVERT(tString,"O","UTF8")
    Set tOutput = $SYSTEM.Encryption.Base64Encode(tString)
}
Write tOutput
</script>
</td></tr>
</table>
</form>

I added  UTF8 conversion:

Set tOutput = $ZCONVERT(tString,"I","UTF8")

and

 Set tString = $ZCONVERT(tString,"O","UTF8")