harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vasily Zakharov (JIRA)" <j...@apache.org>
Subject [jira] Created: (HARMONY-4529) [classlib][swing][html] Relative links in HTML are resolved incorrectly
Date Tue, 24 Jul 2007 23:52:31 GMT
[classlib][swing][html] Relative links in HTML are resolved incorrectly
-----------------------------------------------------------------------

                 Key: HARMONY-4529
                 URL: https://issues.apache.org/jira/browse/HARMONY-4529
             Project: Harmony
          Issue Type: Bug
          Components: Classlib
            Reporter: Vasily Zakharov
         Attachments: Harmony-4529-Fix.patch, testdata.jar

Here's the test to reproduce the problem:

import java.net.URL;
import javax.swing.JEditorPane;
class Test {
    public static void main(String[] args) {
        try {
            URL url = new URL("jar:file:testdata.jar!/resources/index.html");
            new JEditorPane(url);
            System.out.println("SUCCESS");
        } catch (Throwable e) {
            System.out.print("ERROR: ");
            e.printStackTrace(System.out);
        }
    }
}

Don't forget to put the attached testdata.jar file to the same directory as the test.

Output on RI:

SUCCESS

Ouput on Harmony:

ERROR: java.lang.IllegalArgumentException: URI is not absolute: test.gif
        at java.net.URI.toURL(URI.java:1526)
        at javax.swing.text.html.HTML.resolveURL(HTML.java:582)
        at javax.swing.text.html.HTML.resolveURL(HTML.java:564)
        at javax.swing.text.html.ImageView.getImageURL(ImageView.java:76)
        at javax.swing.text.html.ImageView.createImage(ImageView.java:246)
        at javax.swing.text.html.ImageView.setPropertiesFromAttributes(ImageView.java:239)
        at javax.swing.text.html.ImageView.<init>(ImageView.java:65)
        at javax.swing.text.html.HTMLEditorKit$HTMLFactory.create(HTMLEditorKit.java:111)
        at javax.swing.text.CompositeView.loadChildren(CompositeView.java:235)
        at javax.swing.text.FlowView$LogicalView.loadChildren(FlowView.java:259)
        at javax.swing.text.CompositeView.setParent(CompositeView.java:116)
        at javax.swing.text.FlowView.createLogicalView(FlowView.java:44)
        at javax.swing.text.FlowView.loadChildren(FlowView.java:393)
        at javax.swing.text.CompositeView.setParent(CompositeView.java:116)
        at javax.swing.text.html.ParagraphView.setParent(ParagraphView.java:78)
        at javax.swing.text.CompositeView.replace(CompositeView.java:90)
        at javax.swing.text.BoxView.replace(BoxView.java:150)
        at javax.swing.text.CompositeView.loadChildren(CompositeView.java:238)
        at javax.swing.text.CompositeView.setParent(CompositeView.java:116)
        at javax.swing.text.html.BlockView.setParent(BlockView.java:61)
        at javax.swing.text.CompositeView.replace(CompositeView.java:90)
        at javax.swing.text.BoxView.replace(BoxView.java:150)
        at javax.swing.text.CompositeView.loadChildren(CompositeView.java:238)
        at javax.swing.text.CompositeView.setParent(CompositeView.java:116)
        at javax.swing.text.html.BlockView.setParent(BlockView.java:61)
        at javax.swing.text.RootView.replace(RootView.java:266)
        at javax.swing.text.View.append(View.java:273)
        at javax.swing.plaf.basic.BasicTextUI.setView(BasicTextUI.java:864)
        at javax.swing.plaf.basic.BasicTextUI.modelChanged(BasicTextUI.java:767)
        at javax.swing.plaf.basic.BasicTextUI$Listener.propertyChange(BasicTextUI.java:293)
        at java.beans.PropertyChangeSupport.doFirePropertyChange(PropertyChangeSupport.java:263)
        at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:54)
        at java.awt.Component.firePropertyChangeImpl(Component.java:1668)
        at java.awt.Component.firePropertyChange(Component.java:1682)
        at javax.swing.text.JTextComponent.setDocument(JTextComponent.java:143)
        at javax.swing.JEditorPane.setPage(JEditorPane.java:747)
        at javax.swing.JEditorPane.<init>(JEditorPane.java:310)
        at Test.main(Test.java:8)

The reason for this problem is javax.swing.text.html.HTML.resolveURL() method uses URI.resolve(String)
method to resolve links in HTML, and that method doesn't handle JAR URLs correctly.

The attached patch uses URL(URL, String) constructor instead.


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message