administration mode
Pssst...Ferdy is the creator of JungleDragon, an awesome wildlife community. Visit JungleDragon


Ouch »

FERDY CHRISTANT - JUL 26, 2004 (04:44:06 PM)

In my recent HTML Striptease entry I described a technique to strip HTML from user comments. Today, I noticed some really weird behaviour when a user entered a long comment. I was absolutely puzzled. It seemed that my formula randomly removed characters and place new lines. It turns out that it was not so random, and that I was the one to blame. Pay attention to this line of code:

@Explode(@Implode(tmpResult;" ");"##NEWLINE##")

My expectation here was that wherever the character string ##NEWLINE## would appear, it would be replaced by a new line, since I explode it to a list and the multi-value field property is set to display new lines as separators. I was wrong. In reality it will set a new line anytime ONE of the characters is entered. So if a user enters either a #, N, E, W, L, I or N, a new line will be added, but only if they type it in uppercase.

Note to myself: RTFM!

Anyway, here are some updates I have made to mature the comments system:

  • I have fixed the issue above by using the good-old @ReplaceSubString formula
  • I now strip HTML from other comment fields too
  • A loop is rewritten into a single @Transform statement
  • Not only http:// and ftp:// are valid URL starters now, www. is too
  • I have tried to reconstruct the user comments that went wrong manually

Apologies for the mess, and thanks to the users who pointed this out. For the interested, the updated coded can be read here.

Comments: 1


JUL 26, 23:38:01

comment » Looks great. The simpler the better. One last thing that I do with html that has to be stripped is replacing by javascript to protect it from spambots. The js is in a seperate js file that is refered to on every page. I use the javascript that Jake uses

e.g. e-mail «

required field
required field HTML is not allowed. Hyperlinks will automatically be converted.