Closed Bug 74281 Opened 25 years ago Closed 19 years ago

inline style sheet's href is document url (should be null)

Categories

(Core :: DOM: CSS Object Model, defect)

defect
Not set
minor

Tracking

()

RESOLVED FIXED

People

(Reporter: jruderman, Assigned: bzbarsky)

References

Details

(Whiteboard: (py8ieh: file http://www.hixie.ch/tests/evil/dom/css/001.cgi bug))

Attachments

(2 files)

Steps to reproduce: 1. Load http://www.squarefree.com/bookmarklets/ 2a. Type into the location bar: javascript:alert(document.styleSheets[0].href) 2b. Type into the location bar: javascript:document.styleSheets[0].href Result: 2a: See document's href in an alert 2b: See document's href as a new document Expected: 2a: See "null" in the alert. 2b: Nothing should happen, since the function should have returned null. Note: IE has document.styleSheets[0].href return an empty string. I think that's incorrect, since the spec says it should be null. Spec: http://www.w3.org/TR/DOM-Level-2-Style/stylesheets.html#StyleSheets-StyleSheet
Summary: inline style sheet's href is document href (should be null) → inline style sheet's href is document url (should be null)
Not a showstopper currently, aiming for mozilla1.0.
Status: NEW → ASSIGNED
OS: Windows 98 → All
Hardware: PC → All
Target Milestone: --- → mozilla1.0
jst, as long as strings can't be null this can't be implemented, correct? I have a patch that implements IE's behavior (i.e. returns an empty string when the stylesheet is inline) in my tree.
Fabian, you're right, but make your patch call SetDOMStringToNull(theString); and we could check this in, for now it'll only make the string empty, but once we actually support null strings things will work as specified.
peterv, glazou, comments on the patch please?
Comment on attachment 47848 [details] [diff] [review] Proposed fix for bug 74281. Set href to null for inline stylesheets. >+ if(is_inline) { Nit: add a space after the if. r=peterv.
Attachment #47848 - Flags: review+
Comment on attachment 47848 [details] [diff] [review] Proposed fix for bug 74281. Set href to null for inline stylesheets. What peterv said, plus, change mDocument->GetBaseURL() to mDocument->GetDocumentURL(). sr=jst
Attachment #47848 - Flags: superreview+
Hmm, ok, that seems wrong, but I'm ok with this patch as is then (appart from the missing space).
don't forget a whitespace after if in if(!mDocument) r=glazman
Technically, this patch is wrong. If foo.xml contains: <?xml-stylesheet href="foo.xml"?> <yasl xmlns="http://style.example.org/yasl/"> <select target=":root"> <color="green"/> </select> </yasl> ...where yasl is yet another style language, this one in XML, then the stylesheet of that document should have an href even though it is the same URI as the document itself. A contrived case, I agree, but if we're going to be compliant...
I'll let you argue with glazou peterv & jst, I'm not qualified to comment on that ;-)
It occured to me that my patch changes nsCSSStyleSheet:GetHref(), and your example, Hixie, uses another style language. So ns_CSS_StyleSheet shouldn't be called in the first place.
But as I pointed out on IRC, it wouldn't work for a case where the URI of the document and the stylesheet were the same, even though they were different files. e.g., http://www.hixie.ch/tests/evil/dom/css/001.cgi Note that we currently pass this test as far as this bug is concerned (although we do fail to get the right CSS file, unlike IE which passes all versions of this test -- including the cached one).
Whiteboard: (py8ieh: file http://www.hixie.ch/tests/evil/dom/css/001.cgi bug)
To handle that correctly we probably need to rewrite part of the CSS loader.
Bugs targeted at mozilla1.0 without the mozilla1.0 keyword moved to mozilla1.0.1 (you can query for this string to delete spam or retrieve the list of bugs I've moved)
Target Milestone: mozilla1.0 → mozilla1.0.1
Target Milestone: mozilla1.0.1 → ---
Mass-reassigning bugs to dom_bugs@netscape.com
Assignee: jst → dom_bugs
Status: ASSIGNED → NEW
It's got some irrelevant stuff in it and won't compile in debug mode ('cause of const issues), but it's the general idea.
The patch for bug 397427 fixed this. And the test checked in for that bug covers this bug as well.
Assignee: general → bzbarsky
Flags: in-testsuite+
Status: NEW → RESOLVED
Closed: 19 years ago
Depends on: CVE-2008-0593
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: