Author |
Topic |
|
Rob Poretti
Junior Member
Canada
435 Posts |
Posted - 15 June 2001 : 09:18:23
|
Hi,
I'm not sure if a detailed discussion has been had with this subject in mind; if it has, I apologise and I hope someone can direct me to a link...
I've developed a small mod called Display Content. I'm having some difficulty guaranteeing the output format of the text being displayed on another page, so that it does not adversely effect the specific format that is defined by the mod's user. This is due to my lack of knowledge of how the forum pre and post processes posts for displaying it in the forum.
Here is what I need to know in order to do this properly.
1) Can topic subject fields (T_SUBJECT, R_SUBJECT), or forum names (F_SUBJECT) have any formatting whatsoever? Is it just plain text? Can url's, images, or forum code be used it? (I think not, but I gotta ask! If the answer is that no formatting is possible, then I don't have to process these strings, which would otherwise be a waste of server side processing.)
2) With message fields: From what I can tell, it is possible to have both a combination of forum and html tags in a message field, and that this is the case even if html is 'turned off'. For example, a member's signature (which is appended to the topic/reply message before it is posted to the db) can have both types of codes in it -- I have checked in the SQL database for this.
Could you confirm this?
If the above is correct, than I wouldn't mind a Snitz developer comment on the following approach to safely deal with embedded tags (forum or html) when displaying it in a non-forum page:
1) Content headers that are ususally used as links into the forum should be stripped of everything except for textual information. (OF course this processing would not be neccessary if the answer to item 1, above, is NO.)
2) Messages that form the body of the displayed content may be truncated to suit some formatting specification that a user chooses (specifically by using the MessageLength parameter in the DisplayContent mod.) Whenever, the user chooses to display only part of the message, all possible tags must be stripped out. (This is mainly because an end tag could be orphaned as a result of the message getting cut between tags.)
3) Messages that are to be displayed in full can use different formating functions depending on what the user would like to display. If the message is to be displayed just as it might appear in the forum, then the formatStr function in the inc_functions.asp page should be used. (I think that this is the only processing that is used in the topic.asp page for messages.) Alternatively, I could create some other functions to stip out images (escpecially destructive when displaying "unknown" content on a home page or a portal), signatures, or other forum code. This would require a new group of functions in the inc_functions.asp page to singularily remove specific formatting tags.
4) I use Acronym Title html tags in some of the display modes for the mod. If any message field information is placed in an acronym title, it too should have everything stripped from it -- forum code, html tags, signatures, links, etc...
I know that this is a lengthy question/discussion, but by I'm pretty sure some of the issues here have perplexed a number of your "junior developers" and it would be good to have a definitive discussion on this subject... that is... if it hasn't already been had!
Cheers!
Rob Poretti Sascom Marketing Group ~ Toronto vox.905.825.5373 fax.905.825.5960 |
|
animedj
Junior Member
USA
190 Posts |
Posted - 15 June 2001 : 15:02:17
|
Well Rob,
1) No, it can not have any kind of formatting. 2) Well, you can either have Forum code enabled, or HTML code enabled, because if you enable both, the results would be just a very big mess.. but at then end, if either forum code was enabled or not, when you pass it throught formatStr at the moment to pull the information, you get the message formatted in HTML, so that might make it very easy. As you your message formatted from formatStr you can go and strip HTML tags, and for that you can use RegExp to do that. There is an article in www.4guysfromrolla.com where they explained how to do that.
--- Johann Reyes http://animedj.com |
|
|
Rob Poretti
Junior Member
Canada
435 Posts |
Posted - 15 June 2001 : 16:16:31
|
It is possible to enable both html and forum code -- but I've not attempted. My point is, that if it is possible, then someone will do it, and I think I need to guarantee the display of content regardless of how data has been stored in the database.
Even, if both were not enabled, it seems that signatures can have both forum code and html tags in it anyways! (someone correct me about this!) My forum was set to forum code only. When I created a signature, I used forum code to set certain parts of the text to specific colors. When this is appended to the T_MESSAGE or R_MESSAGE fields in the database, it converts some of the forum code to html!. Specifically, although the forum tag for url was kept as forum code, the forum tag for a font color was converted to <font color="red">. So, now I've got both html and forum code in a message...
Now, I could create a function that strips ALL forum code and html code but this is a lot of string processing for a home page on a portal where there could be a LOT of content being displayed. That's why I want to find out exactly what needs to be done and when/where. Only do it when and where it is required.
This is why I need some direction. I could just use a big hammer to solve the problem but then servers may not appreciate it...
Cheers!
Rob Poretti Sascom Marketing Group ~ Toronto vox.905.825.5373 fax.905.825.5960
Edited by - Rob Poretti on 15 June 2001 16:17:22 |
|
|
Rob Poretti
Junior Member
Canada
435 Posts |
|
animedj
Junior Member
USA
190 Posts |
Posted - 15 June 2001 : 17:08:49
|
yeah.. but you gotta see that pretty much, even if forum code is enabled, at the moment that is stored in the database it would be HTML..
Also, yeah.. good method.. here is a function that I build based on that one that can strip out all the HTML tags or a specific one, like img's ..
'################################################################################# '# Function ClearHTMLTags(). '# by Jóhann Haukur Gunnarsson '# '# Variables needed to be defined before calling this '# function are the following: '# '# @strHTML - String to be cleaned up '# @strTag - "" - (Empty) if you want to remove all HTML tags '# Tag - To remove an especific tag ( img, p, b, etc ) '#################################################################################
Function ClearHTMLTags( strHTML, strTag ) ' Variables used in the function dim regEx
' regEx initialization set regEx = New RegExp regEx.IgnoreCase = True regEx.Global = True regEx.Pattern = "<" & strTag & "[^>]*>" strHTML = regEx.Replace( strHTML, "" ) set regEx = nothing ClearHTMLTags = strHTML
end function
--- Johann Reyes http://animedj.com
Edited by - animedj on 15 June 2001 17:27:42 |
|
|
Rob Poretti
Junior Member
Canada
435 Posts |
Posted - 15 June 2001 : 21:14:20
|
Hey Johann!
Thats a good function... very useful, thanks!
I'll probably use it once I know exactly what I'm going to have to remove.
Not all forum codes are stored as html...look at your db in Enterprise Manager or Access... for ex., if you use the url tag in your signature, you will see:
blah (Ok, I give up... I was trying to put the forum codes here and fool it but I couldn't!)
Once again, I could remove (or convert) all forum code and then remove all html tags... but is this really what I should be doing?
I'm hoping a senior member will give me a definitive answer on this...
Cheers!
Rob Poretti Sascom Marketing Group ~ Toronto vox.905.825.5373 fax.905.825.5960
Edited by - Rob Poretti on 15 June 2001 21:15:01
Edited by - Rob Poretti on 15 June 2001 21:16:29
Edited by - Rob Poretti on 15 June 2001 21:17:16
Edited by - Rob Poretti on 15 June 2001 21:17:43
Edited by - Rob Poretti on 15 June 2001 21:18:18
Edited by - Rob Poretti on 15 June 2001 21:19:19 |
|
|
Rob Poretti
Junior Member
Canada
435 Posts |
Posted - 17 June 2001 : 13:06:48
|
I'm sort of responding to my own topic to try and get a definitive response to this... otherwise I will just use the "big hammer" to pull out forum and html code...
Cheers!
Rob Poretti Sascom Marketing Group ~ Toronto vox.905.825.5373 fax.905.825.5960 |
|
|
|
Topic |
|
|
|