Menu

#248 [PATCH] Infinite loop parsing JSP with EOF after slash

v2.0
closed-fixed
5
2007-08-16
2007-07-18
Trejkaz
No

Attempt to parse the attached file and you will get an infinite loop while parsing the JSP tag.

The JSP parser reads the '/'. On reading the next character it gets EOF, determines that this is not a '/' or a '*', and "ungets" the character. But as Page.getCharacter did not actually advance the cursor, effectively this moves the cursor back ready to read the slash again. Hilarity ensues.

The fix could be done in two ways.

1. Modify Lexer.parseJsp so that it doesn't unget the
character in the event of EOF, and perhaps exposes
the stray '/' as an ordinary string.

2. Modify Page.getCharacter so that it does advance
cursor even if it reads an EOF. This sounds
potentially evil but would solve other situations
where similar bugs might occur without having to fix
multiple locations in the code.

I can do the fix myself but I don't want to be the one to make this decision, so please advise. :-)

Problems occurs on stable 1.6 version as well as trunk/2.0.

Discussion

  • Trejkaz

    Trejkaz - 2007-07-26

    Proposed fix for this particular situation.

     
  • Trejkaz

    Trejkaz - 2007-07-26

    Logged In: YES
    user_id=639492
    Originator: YES

    Attaching a patch which fixes this particular example. However some thought should be given to advancing the cursor even in the event of EOF, to fix all similar problems which might be introduced in the future.
    File Added: jsp-infinite-loop-fix.patch

     
  • Trejkaz

    Trejkaz - 2007-07-26
    • summary: Infinite loop parsing JSP with EOF after slash --> [PATCH] Infinite loop parsing JSP with EOF after slash
     
  • Derrick Oswald

    Derrick Oswald - 2007-08-16
    • assigned_to: nobody --> derrickoswald
    • status: open --> closed-fixed
     
  • Derrick Oswald

    Derrick Oswald - 2007-08-16

    Logged In: YES
    user_id=605407
    Originator: NO

    Applied patch provided by Trejkaz.

     

Log in to post a comment.

MongoDB Logo MongoDB