Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 367874 - org.eclipse.wst.sse.ui.internal.derived.HTML2TextReader hangs when reading file with <head>
Summary: org.eclipse.wst.sse.ui.internal.derived.HTML2TextReader hangs when reading fi...
Status: RESOLVED FIXED
Alias: None
Product: WTP Source Editing
Classification: WebTools
Component: wst.html (show other bugs)
Version: unspecified   Edit
Hardware: PC Mac OS X - Carbon (unsup.)
: P3 normal (vote)
Target Milestone: 3.4 M6   Edit
Assignee: Nick Sandonato CLA
QA Contact: Nick Sandonato CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-01-04 11:59 EST by Andrew Eisenberg CLA
Modified: 2012-02-02 11:19 EST (History)
1 user (show)

See Also:


Attachments
patch (1.21 KB, patch)
2012-02-02 11:01 EST, Nick Sandonato CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Eisenberg CLA 2012-01-04 11:59:07 EST
See Bug 367378.  


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.wst.sse.ui.internal.derived.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.

Seems like once an open <head> is found, there needs to be a
lookahead performed to see if a close tag exists.
Comment 1 Nick Sandonato CLA 2012-02-02 11:01:55 EST
Created attachment 210456 [details]
patch

Should stop the infinite loop from occurring.
Comment 2 Nick Sandonato CLA 2012-02-02 11:19:11 EST
Code checked in.