Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 367378 - [implementation] org.eclipse.jface.internal.text.html.HTML2TextReader hangs when reading file with <head>
Summary: [implementation] org.eclipse.jface.internal.text.html.HTML2TextReader hangs w...
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.7.1   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 3.8 M5   Edit
Assignee: Dani Megert CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-21 19:00 EST by Andrew Eisenberg CLA
Modified: 2012-01-04 10:51 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Eisenberg CLA 2011-12-21 19:00:16 EST
When reading a file with an open <head> but no closing </head>, org.eclipse.jface.internal.text.html.HTML2TextReader.read hangs.  Here is a simple main class that reproduces the problem:


public static void main(String[] args) {
        StringReader reader = new StringReader("<head>");
        char[] cb = new char[20];
        try {
            new org.eclipse.jface.internal.text.html.HTML2TextReader(reader, null).read(cb);
        } catch (IOException e) {
            e.printStackTrace();
        }
        System.out.println(cb);
    }

The program goes into an infinite loop.  Change "<head>" to "<head></head>" and the program terminates as expected.

I originally noticed the problem on org.eclipse.wst.sse.ui.internal.derived.HTML2TextReader.HTML2TextReader, but that class is a copy of the jface class of the same name.  The problem appears in both classes.  Seems like once an open <head> is found, there needs to be a lookahead performed to see if a close tag exists.
Comment 1 Dani Megert CLA 2012-01-04 10:51:16 EST
Fixed in master: 60f31587f7b264eca3911ae21d595b0d2e35a568