Closed Bug 421198 Opened 16 years ago Closed 16 years ago

XML does not use style sheet when using relative directory

Categories

(Firefox :: General, defect)

3.0 Branch
x86
Windows XP
defect
Not set
major

Tracking

()

RESOLVED DUPLICATE of bug 397894

People

(Reporter: lukem, Unassigned)

References

Details

Attachments

(1 file)

1.70 KB, application/x-zip-compressed
Details
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9b5pre) Gecko/2008030506 Minefield/3.0b5pre
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9b5pre) Gecko/2008030506 Minefield/3.0b5pre

I have a basic xml document which uses an xsl stylesheet. When the .xsl is in the same directory as the .xml, it displays as expected. When the .xsl is in a different directory (eg:../xsl) then the xml is not displayed properly.

In Firefox3 beta3, it displays as if there is no stylesheet at all.
In nightly build(Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9b5pre) Gecko/2008030506 Minefield/3.0b5pre) it generates an error:
XML Parsing Error: 
Location: file:///c:/xmltest/xml/test.xml
Line Number 2, Column 1:<?xml-stylesheet type="text/xsl" href="../xsl/test.xsl"?>

XML displays fine in Firefox2.

Reproducible: Always

Steps to Reproduce:
1. Generate XML file with stylesheet in a different directory.
2. Load XML in Firefox3 or above.

Actual Results:  
Output displayed incorrectly.

Expected Results:  
Stylesheet should be correctly applied to XML.
Attached file Testcase
After unzipping, open test.xml from xsl directory to see expected output.
Open test.xml from xml directory to see incorrect output. ie: reproduce the bug.
I can confirm this happens for me too in  Firefox 3 Beta 4, fine in 2.0

I did notice however that this only happens if the XML is opened from a local file system (i.e. file:///...) not if it is served from a web server, which makes sense since Firefox probably requests the XSL from the server instead of trying to find it locally (which is where the bug probably lies).
This has happened for me in FF3 for as far as I've tested it (a few weeks).  No problems at all in FF2.

As Jacques said, it only happens when a local file is loaded.

This is an extremely annoying bug, please fix it asap.
Severity: normal → major
Flags: blocking-firefox3?
Version: unspecified → 3.0 Branch
Status: UNCONFIRMED → RESOLVED
Closed: 16 years ago
Resolution: --- → DUPLICATE
Flags: blocking-firefox3?
Using: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9) Gecko/2008052906 Firefox/3.0

In contrast to previous comments, I believe that the bug occurs when resolving the ".." component of the path. It is not simply just because the XSL file is not in the same directory as the XML file. 

i.e <?xml-stylesheet type="text/xsl" href="./conf/xsl/test.xsl" ?> works but i.e <?xml-stylesheet type="text/xsl" href="../conf/xsl/test.xsl" ?> fails where the pertinent files exist in both cases. 

I believe this scenario fails for the same content served off a web-server, but I am not able to check just at the moment.

This is not a bug, it turns out it's a security 'feature'.
See discussion on bug 397894 (and other bugs related to that) for details.

For work around, see:
http://kb.mozillazine.org/Security.fileuri.origin_policy

and:
http://kb.mozillazine.org/Security.fileuri.strict_origin_policy

(In reply to comment #6 from Ben Brookes)

And it isn't possible to rewrite that rule into the working version with one dot?

Thanks for the information about the security policy. I accept I am violating this. After testing, I can confirm (in contrary to my comments above) that this setup *does* work when hosted on a server. I will rewrite my rules to take this into account. Thanks for your help.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: