Solved

Regex to modify the HTML being submitted

Posted on 2014-04-29
3
137 Views
Last Modified: 2015-02-27
Just recently working on one of the websites i have, found one issue:

People were submitting complete iframe tag or complete embed tag inside the table column including the url to run the video..

How can i remove the html around it or santitize it to just keep the url inside intact and add that inside the table column and ignore other html elements

like an example here

<iframe width="420" height="345"
src="http://www.youtube.com/embed/XGSy3_Czz8k">
</iframe>

<embed
width="420" height="345"
src="http://www.youtube.com/v/XGSy3_Czz8k"
type="application/x-shockwave-flash">
</embed>

Open in new window


in the above cases, just remove the html tags and keep the src to insert into the table column,

well it is not happening everytime, couple of users doing this, so also wanna have check if that in form entry, the iframe or embed source is found, then continue..

regards
0
Comment
  • 2
3 Comments
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 500 total points
ID: 40033071
alert('<iframe width="420" height="345" src="http://www.youtube.com/embed/XGSy3_Czz8k"></iframe>'.match(/src="(.+?)"/)[1]);

So var src = tag.match(/src="(.+?)"/)[1];
0
 
LVL 16

Author Comment

by:Gurpreet Singh Randhawa
ID: 40033087
@mplungjan - I have to test it, if this works in coldfusion serverside, i will post the results
0
 
LVL 16

Author Closing Comment

by:Gurpreet Singh Randhawa
ID: 40634923
solved with minor modifications, thx
0

Featured Post

Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hi. There are several upload tutorials using jquery and coldfusion. I found a very interesting one here Upload Your Files using Jquery & ColdFusion and Preview them (http://www.randhawaworld.com/) . I did keep the main js functions but made sever…
I spent nearly three days trying to figure out how incorporate OAuth in Coldfusion for the Eventful API. Hopefully, this article will allow Coldfusion Programmers to buzz through the API when they need to. Basically, what this script does is authori…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question