Intantiation of Buggy CFC Dumps Source to Browser

78 views
Skip to first unread message

Jamie Jackson

unread,
Jul 14, 2014, 11:18:55 AM7/14/14
to ra...@googlegroups.com
I'm just getting started evaluating Railo for a potential ACF9 => Railo site migration.

I'm new to Railo (well, I haven't touched it in a few years), but here's something weird in the version of Railo I'm trying (Railo 4.2.1.000 final).

Test Case:

foo.cfc

component
accessors = true
{
private void function weird() {
writeLog(
file="limiter"
text="hi"
);
}
}

foo.cfm

<cfset rl = createObject("component", "foo") />

If I hit foo.cfm, I get the following in the browser:

component accessors = true { private void function weird() { writeLog( file="limiter" text="hi" ); } }

Yes, there's a bug in foo.cfc (a comma missing between parameters), but why does Railo display the source?

Thanks,
Jamie

Walter Seethaler

unread,
Jul 15, 2014, 11:30:41 AM7/15/14
to ra...@googlegroups.com
Put the accessors attribute in the line with 'component' and vote for:

Jamie Jackson

unread,
Jul 15, 2014, 5:38:06 PM7/15/14
to ra...@googlegroups.com
Hi Walter, I voted.


--
Did you find this reply useful? Help the Railo community and add it to the Railo Server wiki at https://github.com/getrailo/railo/wiki
---
You received this message because you are subscribed to the Google Groups "Railo" group.
To view this discussion on the web visit https://groups.google.com/d/msgid/railo/d06659dc-0ed3-4961-97eb-7e89e74e56f1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Michael Offner

unread,
Jul 16, 2014, 3:46:21 AM7/16/14
to ra...@googlegroups.com
Cfml (Railo/ACF ) is supporting 4 ways to define a component.
1. Tag based component (<cfcomponent/>)
2. Script tag and component (<cfscript>component{}</script>)
3. Script component (component {})
4. Tag based without component tag

The last one needs some explanation.
This is supported in ACF since version 6, so you can do a tag based component without the component tag.

Example for #4:
Hello susi
<cffunction name=test/>

Same as #1:
<cfcomponent>
Hello susi
<cffunction name=test/>
</cfcomponent>

When Railo is parsing a cfc template, it first tries to parse as #1, if this fails #2, if this fails #3 based on the type of error it goes with #4.

So in your case #4 is used, you can see this when you dump the cfc, you have a cfc with no functions, the script code is for Railo simply a string in the body of the component. 
With Railo 5 we already decided to get rid of #4 because it is confusing even we break compatibility to ACF here. When you ask yourself, why you see maybe not the same outcome with ACF, this is simple ACF detects different if it should go for 4 or not. 
Micha
--
Did you find this reply useful? Help the Railo community and add it to the Railo Server wiki at https://github.com/getrailo/railo/wiki
---
You received this message because you are subscribed to the Google Groups "Railo" group.

For more options, visit https://groups.google.com/d/optout.


--
/micha

Michael Offner CTO Railo Technologies GmbH

Walter Seethaler

unread,
Jul 16, 2014, 9:53:39 AM7/16/14
to ra...@googlegroups.com
I see. Even CFB still supports it. Its very ugly, get rid of it or I will end up using it +1

But for the detection of #3 ACF is right, the opening curly bracket of component {} should be allowed to be in a new line. Stuff like this should all work in Railo:

component{}
component
{}
component foo
{
}
component foo="bar"
   baz
{
}

If you don't know about the problem and try to port legacy stuff from ACF, it is a mess.

It also applies for the Application.cfc. When I started with Railo and played with the Application.cfc, I almost gave up because I didn't understand the behaviour and had no compilation errors available because of this. 

Thanks, Walter

Matt Quackenbush

unread,
Jul 16, 2014, 9:58:28 AM7/16/14
to ra...@googlegroups.com
I'm trying to make sure I correctly understand your issue. Are you saying that you have CFCs that do not work if you have the opening brace on a new line, or is the issue limited to cfdump(ing) such CFCs?


--
Did you find this reply useful? Help the Railo community and add it to the Railo Server wiki at https://github.com/getrailo/railo/wiki
---
You received this message because you are subscribed to the Google Groups "Railo" group.

Walter Seethaler

unread,
Jul 16, 2014, 11:09:08 AM7/16/14
to ra...@googlegroups.com
Hi Quack, I am talking about compiler errors.

When you have the following Script component (typo in function), the compiler raises a proper exception with message, template, line and so on and the developer knows "oops, typo".

component{
     funcion bar(){}
}

When your coding style places the bracket in the new line:

component
{
     funcion bar(){}
}

the compiler is not raising an error, but somehow jumps in Micha's #4 - interprets the Component as "tag based component without component tag" and thus interprets the source code as simple text output.
When you create an instance of this class, the source is written in the Output stream (like text in the pseudo constructor of a tag based component) and the returned instance has no method.

When you have a legacy component with a compile error you will end up with a runtime error like: Component Foo does not have a method bar

As I said, if you don't know the problem it's hard to understand the behaviour. In the beginning I strongly believed Railo would not support any compiler errors but just output the source code to "help" the developer.

Matt Quackenbush

unread,
Jul 16, 2014, 12:00:00 PM7/16/14
to ra...@googlegroups.com
Hmm. Interesting. I've never seen that behavior, but perhaps it's because I catch and log exceptions *and* don't use use the default error template.

FWIW, I altered a CFC to introduce the issue described (i.e. `fuction bar() { writeOutput( "foo" ); }`) and I get the exact same message in my error log regardless of where the opening bracket is placed.

Missing [;] or [line feed] after expression

Or maybe the issue you are describing (raw text of the CFC placed into the output stream) only occurs when the CFC is directly called in the browser, e.g. http://mysite.com/myCFC.cfc ? If that's the case, that would easily explain why I've never seen that behavior - I don't directly call CFCs.



--
Did you find this reply useful? Help the Railo community and add it to the Railo Server wiki at https://github.com/getrailo/railo/wiki
---
You received this message because you are subscribed to the Google Groups "Railo" group.

Cameron Childress

unread,
Jul 16, 2014, 3:46:37 PM7/16/14
to ra...@googlegroups.com
On Wed, Jul 16, 2014 at 11:59 AM, Matt Quackenbush <quack...@gmail.com> wrote:
FWIW, I altered a CFC to introduce the issue described (i.e. `fuction bar() { writeOutput( "foo" ); }`) and I get the exact same message in my error log regardless of where the opening bracket is placed.


I can confirm that I have started seeing this error bunch for code that looks similar to:

component
extends = 'Blah'
{
  [some syntax error found here]
}
 

Sometimes the raw source from the CFC shows in the browser and sometimes (if the error is in a CFC further down the inheritance chain) the CFC simply is not invoked at all.

In other words given this scenario:

UserService.cfc ----extends----> Service.cfc

Is Service.cfc has a syntax error it is not reported as an error, it's simply as if Service.cfc never existed and is not called or referenced by UserService.cfc at all.

Or maybe the issue you are describing (raw text of the CFC placed into the output stream) only occurs when the CFC is directly called in the browser, e.g. http://mysite.com/myCFC.cfc ? If that's the case, that would easily explain why I've never seen that behavior - I don't directly call CFCs.

I can report that this is not the case for me. I am not calling it directly, I am using the CFC normally in code.

I'll see if I can work up a test case you can try out.

-Cameron
 
--
Cameron Childress
--
p:   678.637.5072
im: cameroncf

Matt Quackenbush

unread,
Jul 16, 2014, 3:54:13 PM7/16/14
to ra...@googlegroups.com
Wow. That's ........ bizarre. Hopefully extensive unit testing is in place to unmask those syntax errors long before it hits production, but still. :/

Thanks Walter / Cameron.


--
Did you find this reply useful? Help the Railo community and add it to the Railo Server wiki at https://github.com/getrailo/railo/wiki
---
You received this message because you are subscribed to the Google Groups "Railo" group.

Cameron Childress

unread,
Jul 16, 2014, 4:04:17 PM7/16/14
to ra...@googlegroups.com
On Wed, Jul 16, 2014 at 3:53 PM, Matt Quackenbush wrote:
Wow. That's ........ bizarre. Hopefully extensive unit testing is in place to unmask those syntax errors long before it hits production, but still. :/

You would hope so, but this is the sort of thing that Railo can and should handle on it's own. It sure does make debugging a beast.

This super simple test code (syntax error, line 8 of Service.cfc):

Creates this screen output:

You will notice that rather than reporting a line number and error it just spits out the raw CFC code for Service.cfc on the page. Yes, I am using a CFDUMP tag in the example, but the code output comes before that - comment out the dump and you will only see the CFC source.

I'm running Railo 4.2.0.008. I didn't check to see if this is some other unrelated bug that's since fixed - just contributing on this thread since it seems to be the same problem.

-Cameron
 

Cameron Childress

unread,
Jul 16, 2014, 4:14:47 PM7/16/14
to ra...@googlegroups.com
On Wed, Jul 16, 2014 at 4:03 PM, Cameron Childress <came...@gmail.com> wrote:
I'm running Railo 4.2.0.008. I didn't check to see if this is some other unrelated bug that's since fixed - just contributing on this thread since it seems to be the same problem.

Just updated to 4.2.1.002 (most recent development bleeding edge) and I can confirm this same result occurs there too.

-Cameron

Matt Quackenbush

unread,
Jul 16, 2014, 4:18:04 PM7/16/14
to ra...@googlegroups.com


--
Did you find this reply useful? Help the Railo community and add it to the Railo Server wiki at https://github.com/getrailo/railo/wiki
---
You received this message because you are subscribed to the Google Groups "Railo" group.

Jamie Jackson

unread,
Apr 29, 2016, 9:48:03 AM4/29/16
to Railo

Cameron Childress

unread,
May 2, 2016, 8:42:59 AM5/2/16
to ra...@googlegroups.com
On Fri, Apr 29, 2016 at 9:48 AM, Jamie Jackson wrote:

This issue was rejected already for Lucee 4.x. Have you tried it on Lucee 5? They claim it's fixed but I don't have Lucee 5 loaded up yet.

-Cameron
 
Reply all
Reply to author
Forward
0 new messages