开发者

Coldfusion variable to code

I need a way to turn code stored in a variable into real code. We are passing Video embed code inputed from a form through to a page to display the video. Its so that people can 'attach' a shared video from another site to a 开发者_如何转开发post.

<cfoutput>
    #attributes.embed#
</cfoutput>  

simply outputs the code as text


This could open up a security hole depending on what people paste in here. Is it possible to ask visitors to paste in the URL of the shared video and depending on the format of the URL you output it into your own code? Using a switch statement based on the inputted URL, you could provide one output template for YouTube, another for Vimeo, etc.

EDIT

That said, HTML code should output easily unless it has been escaped. However, if you wish to output Coldfusion code, you will need to write the code to a file and then cfinclude the file into your output document. (not recommended, but possible)

EDIT 2

When you 'view source' on the page, do you see angle brackets around the pasted code or angle brackets replaced with &rt and &gt? if you see the &gt then something along the way has encoded the HTML, and you'll need to decode it again with a function around the variable.

<cfoutput>
#decodeFunctionHere(attributes.embed)#
</cfoutput>  

Coldfusion 8 has a decode function named urlDecode if your text is encoded to a url format, using % signs. For &gt &rt another function will need to be used to do the substitution. Should be one on cflib.org or it's easy to write. Let me know.


Found the answer if anyone else is looking: http://speeves.erikin.com/2009/06/coldfusion-replace-html-ized-characters.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜