tracker issue : CF-4116755

select a category, or use search below
(searches all categories and all time range)
Title:

cfxml, cfsavecontent inserting extra whitespace when user defined functions used inline

| View in Tracker

Status/Resolution/Reason: Closed/Withdrawn/NotABug

Reporter/Name(from Bugbase): Bryan Henderson / Bryan Henderson (Bryan Henderson)

Created: 02/11/2016

Components: General Server

Versions: 11.0

Failure Type: Incorrect w/Workaround

Found In Build/Fixed In Build: CF11_Final /

Priority/Frequency: Major / All users will encounter

Locale/System: English / Win 2012 Server x64

Vote Count: 0

Problem Description:  Extra whitespace is being added at the leading hash tag when a user defined function is used.  Note that built in functions do not exhibit this behavior, nor does the use of UDFs outside the cfxml or cfsavecontent tags (other tags that generate/store content between their start and end tags may also be affected)

Steps to Reproduce:  Run the following code to see extraneous whitespace added to the attribute values where the UDF is used:

<cffunction name="echo" returntype="string">
	<cfargument name="value" required="true" />
	<cfreturn arguments.value />
</cffunction>
<cfset myVar = "this" />
<cfset myOtherVar = "snow#echo('flake')#" />
<cfxml variable="test"><cfoutput>
	<mytag
		attrOne="ok"
		attrtwo="#myvar#"
		attrthree="#myvar#ok"
		attrfour="#echo(myvar)#"
		attrfive="dog#echo('house')#"
		attrsix="d#'og' & echo('house')#"
		attrseven="rain#trim(' bow')#"
		attreight="#myOtherVar#"
	/></cfoutput>
</cfxml>
<cfdump var="#toString(test)#" /><br>
<cfsavecontent variable="test2"><cfoutput>
	<mytag
		attrOne="ok"
		attrtwo="#myvar#"
		attrthree="#myvar#ok"
		attrfour="#echo(myvar)#"
		attrfive="dog#echo('house')#"
		attrsix="d#'og' & echo('house')#"
		attrseven="rain#trim(' bow')#"
		attreight="#myOtherVar#"
	/></cfoutput>
</cfsavecontent>
<cfdump var="#test2#" />

Actual Result: the values for the attributes attrfour, attrfive, and attrsix all have a whitespace char in them located at the position of the first hash tag ment to evaluate the UDF:

<?xml version="1.0" encoding="UTF-8"?>
<mytag attrOne="ok"
attreight="snowflake"
attrfive="dog house"
attrfour=" this"
attrseven="rainbow"
attrsix="d oghouse"
attrthree="thisok"
attrtwo="this" /> 

Expected Result: The inline rendering of variables should not include any whitespace as none is included in the variables themselves or added by the UDF

<?xml version="1.0" encoding="UTF-8"?>
<mytag attrOne="ok"
attreight="snowflake"
attrfive="doghouse"
attrfour="this"
attrseven="rainbow"
attrsix="doghouse"
attrthree="thisok"
attrtwo="this" /> 

Any Workarounds: as can be seen in the example "myOtherVar" is generated with the UDF, but does not receive the extra white space because it was generated outside the cfxml tag.  This is the only workaround to guarantee white space is not incorrectly added at the leading hash tag

----------------------------- Additional Watson Details -----------------------------

Watson Bug ID:	4116755

External Customer Info:
External Company:  
External Customer Name: Bryan Henderson
External Customer Email:  
External Test Config: My Hardware and Environment details:



ColdFusion Server Enterprise 11,0,06,295053

Windows Server 2012 R2 AMD64

Attachments:

Comments:

After further testing, the issue may like wi the cfoutput tag as the following code exhibits the same errors: <cfoutput> attrOne="ok" attrtwo="#myvar#" attrthree="#myvar#ok" attrfour="#echo(myvar)#" attrfive="dog#echo('house')#" attrsix="d#'og' & echo('house')#" attrseven="rain#trim(' bow')#" attreight="#myOtherVar#" </cfoutput>
Comment by External U.
4790 | February 11, 2016 10:33:45 AM GMT
I suspect the "problem" is you're writing your functions with tags, and if you're using tags, you need to suppress the indentation in the functions yourself, ie: have output="false" in your function definition. But better to just not use tags for code that's not a view.
Comment by External U.
4791 | February 11, 2016 11:50:46 AM GMT
Thanks Adam adding output="false" to the function definition does resolve the issue.
Comment by External U.
4792 | February 11, 2016 12:08:08 PM GMT
Cool!
Comment by External U.
4793 | February 11, 2016 01:31:49 PM GMT
Closing this bug as it is not an issue and a known behavior. Thanks Adam for your input .
Comment by Suchika S.
4794 | February 12, 2016 12:38:14 AM GMT