Menu

#2 j2h loops indefinitely on \u... inputs

v1.0_(example)
closed
nobody
None
5
2013-07-03
2008-04-25
Mayur Naik
No

Test case:

class C
{
// \uu2028
}

This bug can be fixed by replacing the following code in file src/java/com/java2html/secondparse/JavaCharStream.java:

=====
// Here, we have seen an odd number of backslash's followed by a 'u'
try {
// Modified by JS - BEGIN
char c0 = ReadByte();
while ( (c = c0) == 'u') {
++column;
}

char c1 = ReadByte();
char c2 = ReadByte();
char c3 = ReadByte();

buffer[bufpos] = c = (char) (hexval(c) << 12 |
hexval(c1) << 8 |
hexval(c2) << 4 |
hexval(c3));

column += 4;

//System.out.println("Unicode, column="+column+",line="+line);
//remembers the positon & string of a /u9999 type character
unicodes.put(new Position(column, line), "" + c0 + c1 + c2 + c3);
// Modified by JS - END

}

by the following code:

=====
// Here, we have seen an odd number of backslash's followed by a 'u'
try
{
while ((c = ReadByte()) == 'u')
++column;

char c0 = c;
char c1 = ReadByte();
char c2 = ReadByte();
char c3 = ReadByte();
buffer[bufpos] = c = (char)(hexval(c0) << 12 |
hexval(c1) << 8 |
hexval(c2) << 4 |
hexval(c3));

unicodes.put(new Position(column, line), "" + c0 + c1 + c2 + c3);
column += 4;
}
=====

Discussion

  • Jason S

    Jason S - 2013-07-03
    • status: open --> closed
    • Group: --> v1.0_(example)
     
  • Jason S

    Jason S - 2013-07-03

    thanks, fixed this, and created a test case for it.

    5 years late, but better late than never

     

Log in to post a comment.