Forum Moderators: open

Message Too Old, No Replies

Style code anomaly

need some input checking

         

dingman

9:50 pm on Jun 24, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Has anyone else discovered strange results by accidentally using two closing style codes instead of an open-close pair? I just had a post that appeared below the table it was meant to be in, because I closed a quote block twice rather than opening it. I'm not sure if this is just the first time I've ever made that mistake or if the problem is new.

jatar_k

8:05 am on Jun 25, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



quote tags are the weirdest, there are all kinds of strange things that happen. Other broken tags just show in the posts.

It has been like that for a long time.

Brett_Tabke

12:17 pm on Jun 27, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



It is a very difficult thing to parse for errors. I basically would have to write a validator to insure they are doubled throughout the code.

dingman

4:04 pm on Jun 27, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



For my own forum, I'd rather been thinking of writing something that would push and pop tags from a stack of strings as it went through the message before posting.

However, mine is aimed at *much* smaller user bases than yours - private fora where there are few enough users that every single one personally knows every single other one, and outsiders aren't allowed in. That may let me do things that are prohibitively expensive when you're running a board as big as this one.

vincevincevince

7:04 pm on Jun 27, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



i wrote a similar module before, i did it like this (in php):


$string="The post text";
while (preg_match("/(.*)[ quote](.*)[\/quote](.*)/",$string,$found)) $string=$found[0]."<the html code for open quote>".$found[1]."<the html code for closing quote>".$found[2];

ie - when it finds A PAIR of quote tags it replaces them with the html formatting needed... but i suspect a large regex would be heavy work for your forum brett?

Brett_Tabke

3:08 am on Jun 28, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Ok, ya, ;) now try that loop in a routine gets run an average of 14 million times a day.

killroy

10:09 pm on Jul 3, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Seriously Brett, I've got a VERY computationally expensive site. It runs my own in-memory database engine, non-poersistent I might ad (reloads ALL date from CSVs every script execution, several megs and makes them available to a database middle end) It runs my own scripting language, slow interpretation, several DLLs loaded for commands, NO optimizations.

Ok, not millions per day, but my CPU usage barely breaches 99% most of that 1% is other system stuff...

your average OLD cpu does what, 2000 million operations/sec, let each regex take 10000 operations, divide 14 million by 200000, so you have to spend 70 CPU seconds per day, no sweat. play the numbers, replace the regex with an optimized matching function in C, and you should be game.

Custom parsers, if well written, can rival simple replace operations.

But I didn't say it wouldn't be a load of work ;)))

SN

[edited by: eelixduppy at 8:06 pm (utc) on Feb. 18, 2009]