<cfsavecontent> whitespace options that work in a cfm template do not work in a CFC

Description

When generating output using cfsavecontent, all strategies to suppress whitespace do not work when the code is in a CFC function.

Example code:

<cfprocessingdirective suppresswhitespace="true"> <cfsavecontent variable="addressBlock"> <cfloop from="1" to="6" index="i"> <cfoutput>test_#i# abc</cfoutput> </cfloop> </cfsavecontent> </cfprocessingdirective>

When this is run from within a CFM, the URL-encoded output (so that spaces can be seen) is:

test%5F1%20abctest%5F2%20abctest%5F3%20abctest%5F4%20abctest%5F5%20abctest%5F6%20abc

This is expected behavior. The tabs and line breaks that appear within the tags are not output; only the spaces inherent to the generated strings are output.

When this same code is put into a CFC:

<cfcomponent output="no"> <cffunction name="getChars" output="no"> <cfsetting enablecfoutputonly="true"> <cfprocessingdirective suppresswhitespace="true"> <cfsavecontent variable="addressBlock"> <cfloop from="1" to="6" index="i"> <cfoutput>test_#i# abc</cfoutput> </cfloop> </cfsavecontent> </cfprocessingdirective> <cfreturn addressBlock> </cffunction> </cfcomponent>

and then invoked:

<cfset c=createObject("component","whitespace")> <cfoutput> #c.getChars()# </cfoutput>

the URL-encoded output is:

%0D%0A%09%09%09%09%0D%0A%09%09%09%09%09test%5F1%20abc%0D%0A%09%09%09%09%0D%0A%09%09%09%09%09test%5F2%20abc%0D%0A%09%09%09%09%0D%0A%09%09%09%09%09test%5F3%20abc%0D%0A%09%09%09%09%0D%0A%09%09%09%09%09test%5F4%20abc%0D%0A%09%09%09%09%0D%0A%09%09%09%09%09test%5F5%20abc%0D%0A%09%09%09%09%0D%0A%09%09%09%09%09test%5F6%20abc%0D%0A%09%09%09%09%0D%0A%09%09%09

which is mostly tabs and carriage returns from the code.

The correct behavior would be that the CFC method generates and returns the text without the tabs and carriage returns.

Note that the following strategies have been tried in all combinations to suppress the whitespace from the CFC:

  • smart whitespace management enabled on the server

  • both the <cfcomponent> and <cffunction> tags have attribute output="no" or output="false"

  • <cfsetting enablecfoutputonly="yes/true"> within the CFC function, in combination with using <cfoutput> only around the desired text within the <cfsavecontent>

  • <cfprocessingdirective suppresswhitespace="yes/true"> within the CFC function

As a comparison ACF 10.0 suppresses whitespace (tabs/CR) originating from the code when generating this variable content.

Environment

Windows Server 2012

Activity

Show:

Details

Assignee

Reporter

Priority

New Issue warning screen

Before you create a new Issue, please post to the mailing list first https://dev.lucee.org

Once the issue has been verified, one of the Lucee team will ask you to file an issue

Affects versions

Created 25 August 2016 at 14:03
Updated 19 September 2016 at 08:18

Flag notifications