Bug 423744 - [CSS] Importing a local resource throws a MalformedURLException
Summary: [CSS] Importing a local resource throws a MalformedURLException
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.3   Edit
Hardware: All All
: P3 normal with 1 vote (vote)
Target Milestone: 4.4 M6   Edit
Assignee: Lars Vogel CLA
QA Contact: Daniel Rolka CLA
URL:
Whiteboard:
Keywords: noteworthy
Depends on:
Blocks:
 
Reported: 2013-12-10 14:40 EST by Andrea Guarinoni CLA
Modified: 2014-06-23 10:02 EDT (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrea Guarinoni CLA 2013-12-10 14:40:07 EST
In a theme plug-in, trying to import or use a resource into a CSS stylesheet throws a MalformedURLException at run-time when the '@import url()' is executed. Everything works with no errors when the plug-in is run/debugged into a second Eclipse instance and the package is build succesfully with no error or warning.

eg. if there is a project structure like:

> my.plugin.package.name
    > META-INF/
        > MANIFEST.MF
    > resources/
        > css/
            > base-stylesheet.css
            > win-stylesheet.css
            > linux-stylesheet.css
            > ...
        > images/
            > mytexture.png
            > ...
    > plugin.xml
    > ... 

And into 'linux-stylesheet.css' is imported 'base-stylesheet.css' and used 'mytexture.png':

    @import url("base-stylesheet.css");
    #elemId {
        background-image: url(mytexture.png);
    }

with a 'plugin.xml' like this:

    <?xml version="1.0" encoding="UTF-8"?>
    <?eclipse version="3.4"?>
    <plugin>
       <extension
             point="org.eclipse.e4.ui.css.swt.theme">
          <theme
               basestylesheeturi="resources/css/linux-stylesheet.css"
               id="my.plugin.id"
               label="Theme Name"
               os="linux">
          </theme>
          <theme
              ...
          </theme>
          <property
            name="applicationCSSResources" 
            value="platform:/plugin/my.plugin.id/resources/images/">        
          </property>
       </extension>
    </plugin>

if into CSS is used '@import url("platform:/plugin/my.plugin.id/resources/css/base-stylesheet.css")' where my.plugin.id is the Bundle-SymbolicName assigned in MANIFEST.MF we have the same error both when running/debugging the plugin and when using it after installing the jar.

Probably during plugin execution the workspace directory is automatically assigned to platform:/plugin/org.eclipse.platform/ and cannot be changed and the stylesheets placed into the same plugin directory are unreacheble by the @import.
Comment 1 Lars Vogel CLA 2014-01-21 12:21:11 EST
https://git.eclipse.org/r/#/c/20889/
Comment 3 Lars Vogel CLA 2014-03-04 12:01:55 EST
Verified in Build id: I20140303-2000
Comment 4 Lars Vogel CLA 2014-03-04 12:02:03 EST
Verified
Comment 5 Piotr Tomiak CLA 2014-06-23 09:19:38 EDT
This commit has probably introduced a bug. 

In my CSS I am refering to a plugin resource using absolute URL:

"platform:/plugin/com.genutiec.myeclipse.product/splash.bmp"

When this URL is provided to the OSGiResourceLocator, it resolves fine, because <if (!uri.startsWith("platform:/plugin/"))> blocks prepending startLocation. However when getInputStream is called (because it resolved fine), startLocation is prepended and IOException is thrown.

A possible workaround would be to register another OSGiResourceLocator with startLocation set to "", however if it's not the first one on the list of locators, the exception is thrown anyways and no image loading happens.

I think this bug should be reopened.
Comment 6 Paul Webster CLA 2014-06-23 09:34:04 EDT
(In reply to Piotrek Tomiak from comment #5)
> This commit has probably introduced a bug. 

Piotrek, please open a new bug with the description and how to reproduce, and we'll try and look at it in SR1.  Please reference this bug.

PW
Comment 7 Piotr Tomiak CLA 2014-06-23 10:02:22 EDT
(In reply to Paul Webster from comment #6)
> Piotrek, please open a new bug with the description and how to reproduce,
> and we'll try and look at it in SR1.  Please reference this bug.

Thanks for directions. Filed as bug #437939