1

I have tried to push data to data extension through a landing page using SSJS. The form fields contain HTML characters (which will import to the Data Extension fine). I'm getting this error when I submit the form:

A potentially dangerous Request.Form value was detected from the client 

The error is being thrown because some of these fields contains < and > characters.

I am wondering if there is a way to replace those characters before submitting, or encode them in some way prior to entering the data extension? I know AMPscript has a Replace function, but I'm not sure how I can use it within SSJS to achieve what I'm after.

Is there a Replace function, or something similar within SSJS? Or another way to approach submitting these fields to the data extension?

4 Answers 4

0

Base64Decode() is available in SSJS. You would have to encode before sending in.

http://help.exacttarget.com/en-US/documentation/exacttarget/content/server_side_javascript/server_side_javascript_syntax_guide/core_library_server_side_javascript_functions/utilities_server_side_javascript_functions/

0

You can use the replace function in SSJS as you would do in AMPScript.

I would say the urlencoding function is the right one for encoding, so it stays sort of human-readable in the DE and can be shown on e.g. a cloudpage.

<script type="javascript" runat="server">
Platform.Load("core","1")
var yourinput = "<html></html>";
yourinput = yourinput.replace("<","%3C");
yourinput = yourinput.replace(">","%3E");
Write(yourinput);
</script>

outputs:

%3Chtml%3E

See https://www.urldecoder.org/

0

I had a similar custom application, after some R&D I came up with this approach.

You can also use this approach to pass HTML/XML code from an external application to Marketing Cloud's Landing page.

1) Use the below function to Encode your INPUT field which have your HTML codes.

Encoding using window.btoa() method.

<script type="text/javascript">
document.getElementById('Contentblock').onsubmit = function() 
         {
             var t = window.btoa(document.getElementById('Email_HTML').value);
             document.getElementById('Email_HTML').value = t;
         }
</script>

2) Use the below SSJS function to Decode your request parameter from HTML form.

Decode using Platform.Function.Base64Decode() method.

var Email_HTML = Platform.Function.Base64Decode(Platform.Request.GetFormField('Email_HTML'));
0

Not sure if you still need this, but see my answer on this post.

AMPscript to decode HTML entity in data extension field

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .