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
<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> </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>
Cache version?
Your code runs without errors on 2016.1.
What value are you trying to decode?
Your input is too long, so it's not a string but rather %CSP.CharacterStream.
Here is the base64 of this CCDA (https://raw.githubusercontent.com/chb/sample_ccdas/master/Allscripts%20S...) using this utility (https://sourceforge.net/projects/base64/)
Replaced base64 text with link to it.
I mean can you post it (or any other base64 string giving you an error) here?
I seem unable to reproduce the error.
It's a CCDA in base64
2014.1.4 (Build 803_2U)
Do you just run the page or put some value in textarea?
If I put a short value like "test" in there it encodes, then I copy the base64 and it decodes. If I copy a real base64 CCD it errrors out. Is it a character limitation?
Also please notice that Base64Encode does not work with Unicode characters:
http://docs.intersystems.com/cache20152/csp/documatic/%25CSP.Documatic.c...
<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> </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")
Similar error.
A run-time error occurred while executing the page
ErrorNo: 5002
CSP Page: /csp/ensemble/decode.csp
Namespace: ENSEMBLE
Class: csp.decode
Routine: csp.decode.1
Location: zOnPageHEAD+26
Line: Set tString = $SYSTEM.Encryption.Base64Decode(tString)