cfmail rejecting style statements

145 views Asked by At

For some time I've had code that looks like this:

<cfmail
          from     = "#session.user#"  
          to       = "#PersonEmail1#"          
          password = "#session.password#"
          username = "#session.user#"       
          server   = "localhost"                            
          replyto  = "#session.user#"
          subject  = "#txt['repsubject']#"               
          type     = "html"   >   
 <html>
 <head>
 <style>
     .repbordtop {
      border-top:5px double #A56ABD;
      color: #630D85;
      padding-top: 2px;
   }

</style>
</head>
</html>
   stuff
</cfmail>

I was running it both in Lucee and in ColdFusion 10 and it was working. Occasionally the formatted 'stuff' even came through formatted.

Now, suddenly, it is throwing errors in both Lucee and ColdFusion. In particular it refuses to recognize the style statement. In Lucee I get

missing terminating [#] for expression Stacktrace The Error Occurred in /opt/lucee/tomcat/webapps/ROOT/reports/frag3.cfm: line 25

23:
24: .repbordtop {
25: border-top:5px double #A56ABD;
26: color: #630D85;
27: padding-top: 2px;

whereas in ColdFusion I get:

Invalid CFML construct found on line 25 at column 35. ColdFusion was looking at the following text:

;

The CFML compiler was processing:

An expression that began on line 25, column 28.
The expression might be missing an ending #, for example, #expr instead of #expr#.
The body of a cfmail tag beginning on line 9, column 3.

The error occurred in /home/moxwareo/public_html/reports/frag3.cfm: line 25

23 : 
24 :    .repbordtop {
25 :      border-top:5px double #A56ABD;
26 :      color: #630D85;
27 :      padding-top: 2px;

So it's choking on the same line, and clearly the style tag is not being recognized.

The code I've shown above is what I used to test the problem. I have checked my code in the real program against what I was using when it was working, and there is no difference.

Does anyone have some insight into why the style tag is suddenly not being recognized?

1

There are 1 answers

6
Dan Roberts On

The cfmail body is evaluated just like being wrapped in cfoutput. The hash marks are being seen as the start of a variable/expression to be interpreted and output. To escape # you need to double it ##.