<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>6007</bug_id>
          
          <creation_ts>2005-12-08 04:01:20 -0800</creation_ts>
          <short_desc>WebKit+SVG should have common code to validate uri references</short_desc>
          <delta_ts>2026-10-19 12:19:27 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>SVG</component>
          <version>420+</version>
          <rep_platform>Mac</rep_platform>
          <op_sys>OS X 10.4</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=328066</see_also>
          <bug_file_loc>http://www.w3.org/TR/SVG11/struct.html#Head</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P4</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          <blocked>91791</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Eric Seidel (no email)">eric</reporter>
          <assigned_to name="Rob Buis">rwlbuis</assigned_to>
          <cc>ahmad.saleem792</cc>
    
    <cc>annevk</cc>
    
    <cc>cigitia</cc>
    
    <cc>ian</cc>
    
    <cc>karlcow</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>25712</commentid>
    <comment_count>0</comment_count>
    <who name="Eric Seidel (no email)">eric</who>
    <bug_when>2005-12-08 04:01:20 -0800</bug_when>
    <thetext>WebKit+SVG should have common code to validate uri references

The SVG spec defines exactly what sort of elements can reference other elements in the SVG spec.  
Although we do some checking, we don&apos;t have a nice consistant model.  I think finding a nice way to 
implement this (with a virtual function on SVGElement?) could be a win for both code clarity and spec 
conformance.

For a list of which elements are allowed to map to which others:
http://www.w3.org/TR/SVG11/struct.html#Head</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2166437</commentid>
    <comment_count>1</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2025-12-16 15:42:41 -0800</bug_when>
    <thetext>16.1.5. URL reference attributes
https://svgwg.org/svg2-draft/linking.html#linkRefAttrs

URL references are normally specified with an ‘href’ attribute. The value of this attribute forms a reference for the desired resource (or secondary resource, if there is a fragment identifier). The value of the ‘href’ attribute must be a URL.

Because it is impractical for any application to check that a value is an URL reference, this specification follows the lead of the URL Specification in this matter and imposes no such conformance testing requirement on SVG authoring tools. An invalid URL does not make an SVG document non-conforming. SVG user agents are only required to process URLs when needed, as specified in Processing of URL references.


and https://svgwg.org/svg2-draft/linking.html#processingURL


A lot of the code in 
https://searchfox.org/wubkat/source/Source/WebCore/svg/SVGURIReference.cpp</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2166478</commentid>
    <comment_count>2</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2025-12-16 17:48:01 -0800</bug_when>
    <thetext>Some WPT Tests as well - https://wpt.fyi/results/svg?label=master&amp;label=experimental&amp;aligned&amp;q=url-</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2266176</commentid>
    <comment_count>3</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2026-10-19 12:19:27 -0700</bug_when>
    <thetext>SVG 2 describes one pipeline for URL references:  
https://w3c.github.io/svgwg/svg2-draft/linking.html#processingURL

1. generate the absolute URL, 
2. fetch the document if needed, 
3. identify the target element, 
4. then check it is a valid target. 

WebKit has no single implementation of it.

What exists today:

- SVG href attributes: 
   SVGURIReference::targetElementFromIRIString() finds the element, then each caller checks the type (gradients, pattern, mpath, textPath, use).
- CSS references (clip-path, mask, filter, marker-*, fill, stroke): 
   ReferencedSVGResources::referencedSVGResourceIDs() already holds one table of allowed element types. 
   The id comes from Style::URL::fragment().
- The fragment extraction and the same-document test are also written separately for 
   HTML: Element::findAnchorElementForLink(), 
   LocalFrameView::scrollToFragment(), 
   HTMLLinkElement (rel=expect). 
   They differ in whether the fragment is percent-decoded and in which URL they compare with (document URL or base URL).

Differences found so far:
- percent-encoded ids: clip-path and filter did not decode, the other references did. Bug 328066.
- textPath to a basic shape does not follow later changes to the shape. Bug 328044. Blink accepts only a path there.
- mpath to a shape element: allowed by SVG Animations 2, not by WebKit or Blink. Bug 317648 and Bug 325582.
- use: all three engines are stricter than the SVG 2 table, in different ways. Bug 301280 covers foreignObject.

Not looked at yet: 
* the effect of a base element, xml:base, 
* data: URLs (there is a FIXME in targetElementFromIRIString), 
* the fetch rules (CORS state, secure static mode, SMIL external hrefs), 
* and when a reference is re-resolved after the attribute changes.

One helper function could do the common part: 
1. take a URL, 
2. say whether it points at the current document, 
3. and return the id with percent escapes decoded. 
The SVG attribute path, scroll-to-fragment and rel=expect could all call it. Not proposing it here. 
The differences above are being fixed one by one, and a helper can be considered once they are in.

Or we could close this bug and decides to treat all of this separately. 

I&apos;m updating the URL reference too from SVG 1.1 to SVG 2.0
https://w3c.github.io/svgwg/svg2-draft/struct.html#Head</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>