python/cgi/html bug

Dfenestr8 chrisdewinN0SPAM at
Tue Jan 18 17:42:44 EST 2005


I've written a cgi messageboard script in python, for an irc chan I happen
to frequent.

Bear with me, it's hard for me to describe what the bug is. So I've
divided this post into two sections: HOW MY SCRIPTS WORKS, and WHAT THE


Basically, it's divided into two executable scripts......

One is the thread viewer,, which views threads. When someone
posts a new topic, for instance called "Generic new topic", it creates
a file called "Generic new topic.thread". It stores the post, and any
subsequent posts under in the thread in that file. Nice and simple I

The other executable script is the topic viewer, All that does
is display the topics, by doing a "tops = os.popen('ls -c *.thread')" The
"ls -c" part reads the threads in the order in which they've been
modified, so the first item in the list is always the thread most recently
posted in. 

It then creates an html link to each of the threads ... on the page the
html looks like....

<a href =>foo</a><br>


The problem is when someone posts a new topic, and that topic happens to
have "" double quotes, or any other strange character, some strange
glitches occur. 

Best way to describe is to demonstrate it is go to the forum and try
it yourself. Try entering a topic with straight, ordindary characters, not
that you can re enter the thread any time you want and make new posts
under it. Then try entering a thread with new or whacky characters and see
how far you get.

BTW, if you want to download the script, here it is in gzipped form

More information about the Python-list mailing list