• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Coldfusion tags within query output

New Here ,
Jun 13, 2006 Jun 13, 2006

Copy link to clipboard

Copied

I have a simple query to a SQL database that returns a record set. Within the record set is a field that contains HTML and CFML. When I display the content it reads the CF tags literally. Is there any way to get the CF tags to be processed when it is returned in the query output? See example below.


------------------ CODE ON PAGE -------------------------------
<CFQUERY name="getdata" datasource="DSN">
select ID, HTMLFIELD
from TABLENAME
where ID = '1'
</CFQUERY>

<CFOUTPUT QUERY="getdata">
#getdata.HTMLFIELD#
</CFOUTPUT>


-----------------------VALUE OF "HTMLFIELD" VARIABLE--------------------------------
<CFSET todaysdate = #DateFormat(Now(), "mm/dd/yyyy")#>
<p>Today is #variables.todaysdate#</p>


------------------------WHAT IS DISPLAYED IN THE BROWSER----------------
Today is #variables.todaysdate#


-----------------------WHAT should BE DISPLAYED IN THE BROWSER------------
Today is 06/14/2006
TOPICS
Advanced techniques

Views

219

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jun 13, 2006 Jun 13, 2006

Copy link to clipboard

Copied

Before I tell you how to do this, keep in mind that It is not recommended to allow users to execute CFML. They could delete databases, files, steal info. So if you are going to allow this you need to REALLY REALLY TRUST your users. It is a risky thing to do.

The way you can execute the code would be to write the code to a temporary file, and then use CFINCLUDE to include the file. Then delete the temp file once you are done with it.

But again, make sure you understand the risks before you implement this.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jun 14, 2006 Jun 14, 2006

Copy link to clipboard

Copied

LATEST
Pete is right, very risky.

I've done a similar feature for a site I wrote that allowed users to edit pages on the fly, only I pre-selected functions that could be used and created wrappers for them. Then the users would insert something like $now()$ in the WYSIWYG. Then when the page was requested I would pass the data containing HTML and psuedo-CFML through parse routine which would render the end results in a controlled manner.

I would really recommend this route as you will have much more controll over the types of scripts that can be run. It is also easy to make buttons that insert the code for them.

HTH

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation