Bug 582304 - CSS file @import resolution error with UNC path
Summary: CSS file @import resolution error with UNC path
Status: NEW
Alias: None
Product: Incubator
Classification: Eclipse Project
Component: e4 (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 10
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: E4 Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-08-17 05:04 EDT by Olaf Titz CLA
Modified: 2023-08-17 05:04 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Olaf Titz CLA 2023-08-17 05:04:21 EDT
My RCP application has plug-ins containing CSS stylesheets, where a master stylesheet includes others with @import. When the application runs from an UNC path, the stylesheets are not applied correctly.

This code in AbstractCSSEngine.parseStyleSheet is wrong:

				Path p = new Path(source.getURI());
				IPath trim = p.removeLastSegments(1);
				boolean isArchive = source.getURI().contains(ARCHIVE_IDENTIFIER);
				url = FileLocator
						.resolve(new URL(trim.addTrailingSeparator().toString() + ((CSSImportRule) rule).getHref()));
				File testFile = new File(url.getFile());
				if (!isArchive&&!testFile.exists()) {
					// look in platform default
					String path = getResourcesLocatorManager().resolve((importRule).getHref());
					testFile = new File(new URL(path).getFile());
					if (testFile.exists()) {
						url = new URL(path);
					}
				}


After the first assignment to testFile I get
p = file://fileserver/volume/application/bin/plugins/theme.earth_25.4.89/css/earth.css
trim = file://fileserver/volume/application/bin/plugins/theme.earth_25.4.89/css
isArchive = false
url = file://fileserver/volume/application/bin/plugins/theme.earth_25.4.89/css/earth_main_window_navigation.css
testFile = \volume\application\bin\plugins\theme.earth_25.4.89\css\earth_main_window_navigation.css (WRONG!)

new File(url.getFile()) obviously does not work when the URL contains a host part which should become part of the file name, as is the case with UNC paths. The correct way to convert an URL into a File would be new File(url.toURI()) but this has to be tested.
The behaviour of the following code inside the !isArchive&&!testFile.exists() condition also has to be checked if it works when the whole application resides on an UNC path.