SecurtyHelper.RemoveMarkup

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
8/5/2008 10:33:02 AM
Gravatar
Total Posts 48

SecurtyHelper.RemoveMarkup

Hi Joe,

In my previous post you suggested using the SecurtyHelper.RemoveMarkup to strip any html formatting from a string. This worked great until the returned string contained a malformed tag. I saw the remove markup method is using a regular expression for stripping the html, so I decided I'd try and find a regex that handled malformed tags (I thought this would be a 5 min job lol), however, after reading many many posts on the topic it seems regex's aren't very good at this job.

A few of the posts started pointing to the HtmlAgilityPack so I decided to grab a copy and try it out... I wrote this quick method using it and it has solved all my problems:

public static string RemoveAllMarkup(string text)
{
HtmlDocument doc = new HtmlDocument();
doc.LoadHtml(text);
string plainText = doc.DocumentNode.InnerText;
return plainText;
}

It properly parses the html string unlike the regex and you end up with a nicely stripped string. Just thought i'd point it out as the current removeMarkup could possible be a security risk.

Thanks,

Reiss <<ps my smilies have gone again lol don't seem to be working

 

8/5/2008 10:56:19 AM
Gravatar
Total Posts 18439

Re: SecurtyHelper.RemoveMarkup

Hi Reiss,

It looks like a nice project but I can't use it under their current  license. I've posted in their discussion forum to suggest a license change:

http://www.codeplex.com/htmlagilitypack/Thread/View.aspx?ThreadId=30912

I'll look into that pesky smiley problem again.

Best,

Joe

You must sign in to post in the forums. This thread is closed to new posts.