Link to home
Start Free TrialLog in
Avatar of sglee
sglee

asked on

Coldfusion Error due to # in URL

Hi,
  I have CFM page that used to work just fine, but recently it is generating an error like this:
-------------------------------------------------------------------------------------
Invalid CFML construct found on line 28 at column 189.
ColdFusion was looking at the following text:  /"

The CFML compiler was processing:

An expression that began on line 28, column 179.
The expression might be missing an ending #, for example, #expr instead of #expr#.
The body of a CFMAIL tag beginning on line 20, column 10.
--------------------------------------------------------------------------------------------------

  Here is the statement that is failing.

<a href="https://www.sourcedomain.com/sports/event/050036DC?artistid=873854&majorcatid=10001&minorcatid=1&tm_link=browse_msg-0_0500535DD86A36DC#efeat4212">
<img border="0" src="http://www.mydomain.info/eimage/#Picture#" align="middle">
</a>

  I know it is the # sign that is the causing the problem, but I don't how how to fix this.

Thanks.
ASKER CERTIFIED SOLUTION
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I wouldn't say illegal. Hashbang method in Angular extensively uses #. I think your issue is due to how Coldfusion evaluates the expression.

The problem here is that ColdFusion's IIF() doesn't just evaluate the passed in expressions right away - it uses a double (delayed) evaluation. Therefore, when it goes to evaluate the passed in argument for the second time, it appears as if it contains a ColdFusion expression that is malformed (missing the closing hash symbol).
https://www.bennadel.com/blog/1270-be-careful-using-in-coldfusion-de-expressions.htm
Shaun, I think the one that is a problem is this one in the URL:  #efeat4212
Avatar of sglee
sglee

ASKER

Sorry about the fact that I was not clear which # I thought was causing the error.
It is # in #efeat4212.
The URL provider sends us the URL to insert into our webpage. We just add them to our web page, but this is first time that # was embedded.
In a URL like that, '#' refers to an anchor on the target page.  That's why it is not 'legal' for any other use.
Avatar of sglee

ASKER

User generated image@Dave
"You can try 'percent encoding the '#' as %23" --> it worked!!!

Thank you.
You can escape #  with a double ## - CF will convert to #