SI
SI
discoversearch

We've detected that you're using an ad content blocking browser plug-in or feature. Ads provide a critical source of revenue to the continued operation of Silicon Investor.  We ask that you disable ad blocking while on Silicon Investor in the best interests of our community.  If you are not using an ad blocker but are still receiving this message, make sure your browser's tracking protection is set to the 'standard' level.
Pastimes : Silicon Investor, under the hood

 Public ReplyPrvt ReplyMark as Last ReadFilePrevious 10Next 10PreviousNext  
To: SI Dave who wrote (63)11/30/2005 7:43:19 PM
From: Tom C   of 81
 
The non-compliant html is another issue.

The first person to find a free and sufficiently comprehensive HTML stripper

I'm going to assume you are talking about the profile page and you don’t mean to disable html altogether since that is easily accomplished using the HttpUtility.HtmlEncode() function.

I was going to try this out myself but I haven’t had the time but I’ll throw it out there anyway. Keep in mind this is not compiled or tested.

If you want to allow some html tags but not others I would try using the XmlDocument class. HTML is close to XML compliant with some notable exceptions like the <img source=xxx.gif> and <br> tags. In each case you can replace the > with /> to make them compliant.

Add you own tags for those plain old text fields after forcing some tags into compliance with XML:

xmlDoc.LoadXml(“<Company>” + txtbox.text + “</Company>”)

catch any exceptions. If it throws an exception then htmlEncode() the txtbox.text.

If it loads then the there are no unclosed tags.
Once in the document object you can inspect each of the tags to ensure that they are allowed.

System.Xml.XmlNodeList xmlTags = XmlCmdDoc.SelectNodes("/Company");

Loop through the tags and make sure they are allowed.

for (int i = 0; i < xmlTags.Count; i++) {
if (!InAllowedTagList(xmlTags.Name) ) {
return HttpUtility.HtmlEncode (txtbox.text)
}
}

return txtbox.text;
Report TOU ViolationShare This Post
 Public ReplyPrvt ReplyMark as Last ReadFilePrevious 10Next 10PreviousNext