Solved

Regex to modify the HTML being submitted

Posted on 2014-04-29
3
131 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 15

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 15

Author Closing Comment

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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article  is about submitting  form through  ColdFusion.Ajax.submitForm to the action page and send a response back in JSON format which later can be decoded using ColdFusion.JSON.decode. By this way you can avoid the usual page refresh for subm…
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…

932 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now