python/cgi/html bug

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dfenestr8

    #1

    python/cgi/html bug

    Hi.

    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
    BUG IS.



    HOW MY SCRIPT WORKS

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

    One is the thread viewer, ppthread.py, 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
    figured.

    The other executable script is the topic viewer, pptopic.py. 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 = ppthread.py?sub ject=foo>foo</a><br>

    WHAT THE BUG IS ....

    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.

    http://funkmunch.net/~pirch/cgi-bin/...rum/pptopic.py

    BTW, if you want to download the script, here it is in gzipped form
    http://funkmunch.net/~pirch/pepperpot.tgz





  • Dan Bishop

    #2
    Re: python/cgi/html bug


    Dfenestr8 wrote:[color=blue]
    > Hi.
    >
    > I've written a cgi messageboard script in python, for an irc chan I[/color]
    happen[color=blue]
    > 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[/color]
    THE[color=blue]
    > BUG IS.
    > ...
    > The problem is when someone posts a new topic, and that topic happens[/color]
    to[color=blue]
    > have "" double quotes, or any other strange character, some strange
    > glitches occur.[/color]

    Use cgi.escape(topi c, True) to convert HTML special characters to the
    equivalent ampersand escape sequences.

    Comment

    • Dfenestr8

      #3
      Re: python/cgi/html bug

      On Tue, 18 Jan 2005 21:50:58 -0800, Dan Bishop wrote:
      [color=blue]
      >
      > Dfenestr8 wrote:[color=green]
      >> Hi.
      >>
      >> I've written a cgi messageboard script in python, for an irc chan I[/color]
      > happen[color=green]
      >> 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[/color]
      > THE[color=green]
      >> BUG IS.
      >> ...
      >> The problem is when someone posts a new topic, and that topic happens[/color]
      > to[color=green]
      >> have "" double quotes, or any other strange character, some strange
      >> glitches occur.[/color]
      >
      > Use cgi.escape(topi c, True) to convert HTML special characters to the
      > equivalent ampersand escape sequences.[/color]

      Thanx.

      Seems to work now. :)

      Comment

      • Fuzzyman

        #4
        Re: python/cgi/html bug


        Dfenestr8 wrote:[color=blue]
        > Hi.
        >
        > I've written a cgi messageboard script in python, for an irc chan I[/color]
        happen[color=blue]
        > to frequent.
        >[/color]

        This looks very good.
        I've been looking for a python messageboard CGI for a long time.

        If you wanted to add user accounts/login/admin etc. you could use
        'Login Tools'. This is a python module built especially to do that. It
        also provides a convenient way of saving user preferences etc.

        http://www.voidspace.org.uk/python/logintools.html

        If you want any help using it then feel free to ask.

        Regards,

        Fuzzy
        http://www.voidspace.org.uk/python/index.shtml
        [color=blue]
        > 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[/color]
        THE[color=blue]
        > BUG IS.
        >
        >
        >
        > HOW MY SCRIPT WORKS
        >
        > Basically, it's divided into two executable scripts......
        >
        > One is the thread viewer, ppthread.py, which views threads. When[/color]
        someone[color=blue]
        > posts a new topic, for instance called "Generic new topic", it[/color]
        creates[color=blue]
        > 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
        > figured.
        >
        > The other executable script is the topic viewer, pptopic.py. All that[/color]
        does[color=blue]
        > is display the topics, by doing a "tops = os.popen('ls -c *.thread')"[/color]
        The[color=blue]
        > "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[/color]
        recently[color=blue]
        > posted in.
        >
        > It then creates an html link to each of the threads ... on the page[/color]
        the[color=blue]
        > html looks like....
        >
        > <a href = ppthread.py?sub ject=foo>foo</a><br>
        >
        > WHAT THE BUG IS ....
        >
        > The problem is when someone posts a new topic, and that topic happens[/color]
        to[color=blue]
        > 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[/color]
        characters, not[color=blue]
        > 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[/color]
        and see[color=blue]
        > how far you get.
        >
        > http://funkmunch.net/~pirch/cgi-bin/...rum/pptopic.py
        >
        > BTW, if you want to download the script, here it is in gzipped form
        > http://funkmunch.net/~pirch/pepperpot.tgz[/color]

        Comment

        • Dfenestr8

          #5
          Re: python/cgi/html bug

          On Wed, 19 Jan 2005 04:32:04 -0800, Fuzzyman wrote:
          [color=blue]
          > This looks very good.
          > I've been looking for a python messageboard CGI for a long time.
          >[/color]

          Thanx!

          No glaring security holes that you noticed? Other than being able to hide
          things in html tags?
          [color=blue]
          > If you wanted to add user accounts/login/admin etc. you could use 'Login
          > Tools'. This is a python module built especially to do that. It also
          > provides a convenient way of saving user preferences etc.
          >
          > http://www.voidspace.org.uk/python/logintools.html
          >
          > If you want any help using it then feel free to ask.
          >
          > Regards,[/color]

          Comment

          • Paul Rubin

            #6
            Re: python/cgi/html bug

            Dfenestr8 <chrisdewinN0SP AM@yahoo.com.au > writes:[color=blue]
            > No glaring security holes that you noticed? Other than being able to hide
            > things in html tags?[/color]

            Looks like you can also embed arbitrary javascript (I just tried it).
            I haven't looked at the script itself yet.

            Comment

            • Dfenestr8

              #7
              Re: python/cgi/html bug

              On Wed, 19 Jan 2005 12:15:18 -0800, Paul Rubin wrote:
              [color=blue]
              > Dfenestr8 <chrisdewinN0SP AM@yahoo.com.au > writes:[color=green]
              >> No glaring security holes that you noticed? Other than being able to
              >> hide things in html tags?[/color]
              >
              > Looks like you can also embed arbitrary javascript (I just tried it). I
              > haven't looked at the script itself yet.[/color]

              fixed that.
              try doing it now......

              http://funkmunch.net/~pirch/cgi-bin/...rum/pptopic.py

              Comment

              Working...