Bug 140488

Summary: WebKit ignores HTML <base> when resolving URIs like xlink:href="#foo", in SVG within HTML
Product: WebKit Reporter: Daniel Holbert <dholbert>
Component: SVGAssignee: Nobody <webkit-unassigned>
Status: RESOLVED CONFIGURATION CHANGED    
Severity: Normal CC: ahmad.saleem792, ap, bbrinza, bfulgham, rniwa, simon.fraser, zimmermann
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
See Also: https://bugzilla.mozilla.org/show_bug.cgi?id=1121708
http://code.google.com/p/chromium/issues/detail?id=449027
https://bugs.webkit.org/show_bug.cgi?id=189499
Attachments:
Description Flags
testcase 1 none

Description Daniel Holbert 2015-01-14 20:02:21 PST
Created attachment 244675 [details]
testcase 1

STEPS TO REPRODUCE:
  View attached testcase.
(which is a slightly tweaked version of https://bug1121708.bugzilla.mozilla.org/attachment.cgi?id=8549260 )

EXPECTED RESULTS
  One blue rect.

ACTUAL RESULTS:
  Two blue rects.

Please use labels and text to provide additional information.
  The second blue rect is from a <use> element, with xlink:href="#original-rect". The problem is, there's a <base> element, which is supposed to set the base URL to be used when resolving relative URLs in attributes in the document (including this xlink:href attribute), as described at https://html.spec.whatwg.org/multipage/semantics.html#the-base-element

So, the xlink:href="#original-rect" URL *should* be interpreted as "/foo#original-rect", which doesn't resolve to anything (in this case), so nothing should show up.

See also https://bugzilla.mozilla.org/show_bug.cgi?id=1121708 for a discussion of how this works in Firefox. I'm filing this bug here in the hopes of getting interoperability on this.


NOTE: I filed this on Blink here: https://code.google.com/p/chromium/issues/detail?id=449027

VERSION INFO:
WebKit version tested: Midori version 0.4.3, which reports itself as using "WebKitGTK+" version "1.10.1 (2.4.6)" (in about:version) 
I also tested Safari 8 on OS X Yosemite.  Same results in each. (and in Chrome)

Firefox matches my EXPECTED RESULTS.

See https://bugzilla.mozilla.org/show_bug.cgi?id=1121708 for discussion on Firefox's behavior.
Comment 1 bbrinza@microsoft.com 2016-02-03 20:34:46 PST
Blink bug was fixed and now the pages with <base> work interoperably in Edge, Chrome (canary) and Firefox, but not Safari/WebKit

This was resolved last August during Paris face to face SVG WG meeting - https://www.w3.org/2015/08/25-svg-minutes.html#item08
Comment 2 Simon Fraser (smfr) 2018-11-10 12:17:18 PST
This behavior was changed via https://github.com/w3c/svgwg/issues/61. CSS Values now has <https://drafts.csswg.org/css-values/#local-urls>:

"When matching a url() with the local url flag set, ignore everything but the URL’s fragment, and resolve that fragment against the current document that relative URLs are resolved against."
Comment 3 Ahmad Saleem 2022-07-10 11:42:03 PDT
I am unable to get "Expected Result" based on attached test case in Safari 15.5 on macOS 12.4 and Safari Technical Preview 148 but the actual results (of two blue rects) is now consistent with other browsers (Chrome Canary 105 and Firefox Nightly 104).

Further, Comment 02 mentioned an update in Web-Spec, should this be marked as "RESOLVED INVALID" or "RESOLVED CONFIGURATION CHANGED"? Thanks!
Comment 4 Ryosuke Niwa 2022-07-10 12:32:44 PDT
Yeah, this is config changed.