After doing some research and working on CF 2016 there is one problem that I found. I use JQuery/Ajax to submit form data. If I enter semi column ;
in one of my text areas that symbols is converted to ;
. I'm not sure what is causing semi column to convert to HTML code. I have checked data form before gets submitted and if I enter Test;
in console this will look like: Test%3B
. Then I have dumped form scope in cfmail on the top of my cffunction and form field value looks like this: Test;
Here is example that I created of my HTML/JQuery code:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=10; IE=11" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Test Page</title>
<script type="text/javascript" src="JQuery/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="JQuery/jquery-ui.js"></script>
</head>
<body>
<div id="myContainer">
<form name="myForm" id="myForm" method="POST" action="#" class="frmSubmitData">
<fieldset>
<legend>Test Form</legend>
<div>
<span style="display: inline-block; vertical-align:top; font-weight:bold;">Comments:</span>
<textarea name="my_comments" id="my_comments" row="2" cols="55" required></textarea>
</div>
<div>
<input type="submit" name="frmSubmit" id="frmSubmit" value="Submit" />
</div>
</fieldset>
</form>
</div>
<script>
$('.frmSubmitData').on('submit', function(e){
e.preventDefault();
var formData = $('#myForm').serialize();
console.log(formData);
$.ajax({
type: 'POST',
encoding:"UTF-8",
url: 'Components/myTest.cfc?method=testForm',
data: formData,
dataType: 'json'
}).done(function(obj){
if(obj.STATUS === 200){
console.log(obj.FORMDATA);
}else{
alert('Error');
}
}).fail(function(jqXHR, textStatus, errorThrown){
alert("Error: "+errorThrown);
});
});
</script>
</body>
</html>
and example of coldfusion function:
<cfcomponent>
<cfsetting enablecfoutputonly="yes" showdebugoutput="no" requesttimeout="3600">
<cffunction name="testForm" access="remote" output="true" returnformat="JSON">
<cfmail to="myemail@gmail.com" from="myemail@gmail.com" subject="Test Form Scope" type="text">
<cfloop collection="#form#" item="theField">
<cfoutput>#theField# = #form[theField]#<br></cfoutput>
</cfloop>
</cfmail>
<cfset fnResults = StructNew()>
<cfset fnResults.message = "Record successfully saved.">
<cfset fnResults.status = "200">
<cfset fnResults.formdata = #FORM#>
<cfreturn fnResults>
</cffunction>
</cfcomponent>
One note before I finish this code worked fine on CF10, once we upgraded to CF 2016 this problem showed up. Again same exact client side code was used before and semi column charters were not converted. If anyone experienced the same problem and know how to fix this please let me know. Thank you!