<?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>13611</bug_id>
          
          <creation_ts>2007-05-07 08:48:20 -0700</creation_ts>
          <short_desc>Crash in setAttributeNS setting href of SVG &lt;use&gt; to nonexistent symbol</short_desc>
          <delta_ts>2007-07-16 12:19:41 -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>523.x (Safari 3)</version>
          <rep_platform>Mac</rep_platform>
          <op_sys>OS X 10.4</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P1</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Gera Weiss">gera.weiss</reporter>
          <assigned_to name="Nikolas Zimmermann">zimmermann</assigned_to>
          
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>11019</commentid>
    <comment_count>0</comment_count>
    <who name="Gera Weiss">gera.weiss</who>
    <bug_when>2007-05-07 08:48:20 -0700</bug_when>
    <thetext>&lt;?xml version=&quot;1.0&quot;?&gt;
&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot;
 xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot; onload=&quot;init()&quot;&gt;
 &lt;script&gt;&lt;![CDATA[
 function init() {
 	alert(&quot;Wait&quot;)
  	var c= document.getElementById(&quot;tt&quot;)
  	c.setAttributeNS(&quot;http://www.w3.org/1999/xlink&quot;,&quot;href&quot;,&quot;#no&quot;)
  	alert(&quot;Done&quot;)
 }
]]&gt;
&lt;/script&gt;

&lt;use id=&quot;tt&quot; xlink:href=&quot;#no&quot;/&gt; 

&lt;/svg&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>11029</commentid>
    <comment_count>1</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2007-05-07 11:46:14 -0700</bug_when>
    <thetext>ASSERTION FAILED: target
(/Users/ap/WebKit/WebCore/ksvg2/svg/SVGUseElement.cpp:242 virtual void WebCore::SVGUseElement::buildPendingResource())

Crashes release build.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>10680</commentid>
    <comment_count>2</comment_count>
    <who name="Eric Seidel (no email)">eric</who>
    <bug_when>2007-05-08 04:06:03 -0700</bug_when>
    <thetext>Ok, well this is a brute-force fix:

Index: ksvg2/svg/SVGUseElement.cpp
===================================================================
--- ksvg2/svg/SVGUseElement.cpp	(revision 21299)
+++ ksvg2/svg/SVGUseElement.cpp	(working copy)
@@ -142,10 +142,14 @@
     if (!attached())
        return;
 
+    // do a complete rebuild of the renderer if the target changed.
+    if (attr-&gt;name().matches(XLinkNames::hrefAttr)) {
+        detach();
+        attach();
+    }
     // Only update the tree if x/y/width/height or xlink:href changed.
-    if (attr-&gt;name() == SVGNames::xAttr || attr-&gt;name() == SVGNames::yAttr ||
-        attr-&gt;name() == SVGNames::widthAttr || attr-&gt;name() == SVGNames::heightAttr ||
-        attr-&gt;name().matches(XLinkNames::hrefAttr))
+    else if (attr-&gt;name() == SVGNames::xAttr || attr-&gt;name() == SVGNames::yAttr ||
+        attr-&gt;name() == SVGNames::widthAttr || attr-&gt;name() == SVGNames::heightAttr)
         buildPendingResource();
     else if (m_shadowTreeRootElement)
         m_shadowTreeRootElement-&gt;setChanged();
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>10681</commentid>
    <comment_count>3</comment_count>
      <attachid>14409</attachid>
    <who name="Eric Seidel (no email)">eric</who>
    <bug_when>2007-05-08 04:17:31 -0700</bug_when>
    <thetext>Created attachment 14409
Better test case

This test case tests both the crash, as well as testing to make sure that the id gets added to the pending list if appropriate.  (My above simple fix does not handle that case properly).

This example shows how fragile the current pending list system is... but that&apos;s a subject for another bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>10682</commentid>
    <comment_count>4</comment_count>
    <who name="Eric Seidel (no email)">eric</who>
    <bug_when>2007-05-08 04:19:58 -0700</bug_when>
    <thetext>Actually, the pending list issue may need to be split out.  Even if &quot;#green&quot; is part of the initial source text, WebKit still doesn&apos;t notice when &quot;wrongname&quot; changes to &quot;green&quot; and properly update the document.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>8624</commentid>
    <comment_count>5</comment_count>
    <who name="Eric Seidel (no email)">eric</who>
    <bug_when>2007-05-31 13:52:57 -0700</bug_when>
    <thetext>A slightly more complete brute-force fix:

Index: ksvg2/svg/SVGUseElement.cpp
===================================================================
--- ksvg2/svg/SVGUseElement.cpp (revision 21912)
+++ ksvg2/svg/SVGUseElement.cpp (working copy)
@@ -142,10 +142,15 @@
     if (!attached())
        return;
 
-    // Only update the tree if x/y/width/height or xlink:href changed.
-    if (attr-&gt;name() == SVGNames::xAttr || attr-&gt;name() == SVGNames::yAttr ||
-        attr-&gt;name() == SVGNames::widthAttr || attr-&gt;name() == SVGNames::heightAttr ||
-        attr-&gt;name().matches(XLinkNames::hrefAttr))
+    if (attr-&gt;name().matches(XLinkNames::hrefAttr)) {
+        // if the target changed recreate the entire rendering sub-tree
+        detach();
+        m_targetElementInstance = 0;
+        m_shadowTreeRootElement = 0;
+        attach();
+    } else if (attr-&gt;name() == SVGNames::xAttr || attr-&gt;name() == SVGNames::yAttr ||
+        attr-&gt;name() == SVGNames::widthAttr || attr-&gt;name() == SVGNames::heightAttr)
+        // otherwise only update the tree if x/y/width/height changed.
         buildPendingResource();
     else if (m_shadowTreeRootElement)
         m_shadowTreeRootElement-&gt;setChanged();</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>7920</commentid>
    <comment_count>6</comment_count>
    <who name="Nikolas Zimmermann">zimmermann</who>
    <bug_when>2007-06-11 17:44:31 -0700</bug_when>
    <thetext>Investigate to find a real fix for the xlink:href problems, which don&apos;t involve detach/attach.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>4635</commentid>
    <comment_count>7</comment_count>
    <who name="Nikolas Zimmermann">zimmermann</who>
    <bug_when>2007-07-16 06:34:35 -0700</bug_when>
    <thetext>This doesn&apos;t crash anymore in feature-branch. Though it just silently ignores the request, instead of cleaning up the use element, to not show anything anymore. About to fix that.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>4606</commentid>
    <comment_count>8</comment_count>
    <who name="Nikolas Zimmermann">zimmermann</who>
    <bug_when>2007-07-16 12:19:41 -0700</bug_when>
    <thetext>Landed in r24320.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>14409</attachid>
            <date>2007-05-08 04:17:31 -0700</date>
            <delta_ts>2007-05-08 04:17:31 -0700</delta_ts>
            <desc>Better test case</desc>
            <filename>test.svg</filename>
            <type>image/svg+xml</type>
            <size>781</size>
            <attacher name="Eric Seidel (no email)">eric</attacher>
            
              <data encoding="base64">PD94bWwgdmVyc2lvbj0iMS4wIj8+CjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAv
c3ZnIgogeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG9ubG9hZD0i
aW5pdCgpIj4KIDxzY3JpcHQ+CiAgIDwhW0NEQVRBWwogICAgdmFyIHhsaW5rTnMgPSAiaHR0cDov
L3d3dy53My5vcmcvMTk5OS94bGluayI7CiAgICAgIGZ1bmN0aW9uIGluaXQoKSB7CiAgICAgICAg
dmFyIGMgPSBkb2N1bWVudC5nZXRFbGVtZW50QnlJZCgidHQiKTsKICAgIAogICAgICAgIC8vIFRo
aXMgbGluZSBjaGVja3MgZm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