<?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>24421</bug_id>
          
          <creation_ts>2009-03-06 02:33:59 -0800</creation_ts>
          <short_desc>CSS from STYLE tag is applied to page even when STYLE element is not in the document</short_desc>
          <delta_ts>2023-12-29 02:50:41 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>DOM</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows XP</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>CONFIGURATION CHANGED</resolution>
          
          
          <bug_file_loc>http://ua.zapatec.net/~vanger/webkit-css-innerhtml-bug.html</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>0</everconfirmed>
          <reporter name="Andrew Kulinich">b30r4</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>annevk</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>112561</commentid>
    <comment_count>0</comment_count>
    <who name="Andrew Kulinich">b30r4</who>
    <bug_when>2009-03-06 02:33:59 -0800</bug_when>
    <thetext>I&apos;m doing pre-parsing of HTML strings before dispaying them to page to cut off forbidden tags. To do this I&apos;m creating element in the DOM but do not add it into main page to not affect page layout, assigning innerHTML to this string and after that processing new DOM tree to delete forbidden elements. After that I&apos;m compressing element content into HTML string and inserting it into page.
This works ok with all the browsers but in Webkit I got an error - if HTML string contains &lt;STYLE&gt; tag - CSS rules from that element are applied to main page even if temporary element is not in the main page DOM.
See attached example.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>112562</commentid>
    <comment_count>1</comment_count>
      <attachid>28354</attachid>
    <who name="Andrew Kulinich">b30r4</who>
    <bug_when>2009-03-06 02:35:30 -0800</bug_when>
    <thetext>Created attachment 28354
example to reproduce an error</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>112567</commentid>
    <comment_count>2</comment_count>
    <who name="Andrew Kulinich">b30r4</who>
    <bug_when>2009-03-06 03:52:44 -0800</bug_when>
    <thetext>Workaround - use createElementNS to create element in different namespace - in this case STYLE won&apos;t affect local document.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>112568</commentid>
    <comment_count>3</comment_count>
    <who name="Andrew Kulinich">b30r4</who>
    <bug_when>2009-03-06 04:32:53 -0800</bug_when>
    <thetext>same problem with &lt;LINK&gt; element - for LINK rel=&quot;stylesheet&quot; corresponding CSS file is loaded and applied to the page</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>112573</commentid>
    <comment_count>4</comment_count>
      <attachid>28357</attachid>
    <who name="Andrew Kulinich">b30r4</who>
    <bug_when>2009-03-06 06:07:47 -0800</bug_when>
    <thetext>Created attachment 28357
XSS</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>112574</commentid>
    <comment_count>5</comment_count>
    <who name="Andrew Kulinich">b30r4</who>
    <bug_when>2009-03-06 06:16:08 -0800</bug_when>
    <thetext>attached new file - XSS attack using this bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2002203</commentid>
    <comment_count>6</comment_count>
    <who name="Anne van Kesteren">annevk</who>
    <bug_when>2023-12-29 02:50:41 -0800</bug_when>
    <thetext>This seems to be working fine today.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>28354</attachid>
            <date>2009-03-06 02:35:30 -0800</date>
            <delta_ts>2009-03-06 02:35:30 -0800</delta_ts>
            <desc>example to reproduce an error</desc>
            <filename>test.html</filename>
            <type>text/html</type>
            <size>376</size>
            <attacher name="Andrew Kulinich">b30r4</attacher>
            
              <data encoding="base64">PCFET0NUWVBFIGh0bWwgUFVCTElDICItLy9XM0MvL0RURCBYSFRNTCAxLjAgVHJhbnNpdGlvbmFs
Ly9FTiIgImh0dHA6Ly93d3cudzMub3JnL1RSL3hodG1sMS9EVEQveGh0bWwxLXRyYW5zaXRpb25h
bC5kdGQiPg0KPGh0bWw+PGhlYWQ+PHRpdGxlPjwvdGl0bGU+PC9oZWFkPjxib2R5Pg0KPHNjcmlw
dCB0eXBlPSJ0ZXh0L2phdmFzY3JpcHQiPg0KdmFyIGRpdiA9IGRvY3VtZW50LmNyZWF0ZUVsZW1l
bnQoImRpdiIpOw0KdmFyIGNvbnRlbnQgPSAiPGRpdj48c3R5bGU+PCEtLSBCT0RZIHsgYmFja2dy
b3VuZC1jb2xvcjogcmVkO30gLS0+PFwvc3R5bGU+PFwvZGl2PiINCmRpdi5pbm5lckhUTUwgPSBj
b250ZW50Ow0KPC9zY3JpcHQ+DQo8L2JvZHk+PC9odG1sPg==
</data>

          </attachment>
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>28357</attachid>
            <date>2009-03-06 06:07:47 -0800</date>
            <delta_ts>2009-03-06 06:07:47 -0800</delta_ts>
            <desc>XSS</desc>
            <filename>test.html</filename>
            <type>text/html</type>
            <size>392</size>
            <attacher name="Andrew Kulinich">b30r4</attacher>
            
              <data encoding="base64">PCFET0NUWVBFIGh0bWwgUFVCTElDICItLy9XM0MvL0RURCBYSFRNTCAxLjAgVHJhbnNpdGlvbmFs
Ly9FTiIgImh0dHA6Ly93d3cudzMub3JnL1RSL3hodG1sMS9EVEQveGh0bWwxLXRyYW5zaXRpb25h
bC5kdGQiPg0KPGh0bWw+PGhlYWQ+PHRpdGxlPjwvdGl0bGU+PC9oZWFkPjxib2R5Pg0KPHNjcmlw
dCB0eXBlPSJ0ZXh0L2phdmFzY3JpcHQiPg0KdmFyIGRpdiA9IGRvY3VtZW50LmNyZWF0ZUVsZW1l
bnQoImRpdiIpOw0KdmFyIGNvbnRlbnQgPSAnPGRpdj48TUVUQSBIVFRQLUVRVUlWPSJyZWZyZXNo
IiBDT05URU5UPSIwO3VybD1qYXZhc2NyaXB0OmFsZXJ0KFwnWFNTXCcpOyI+PFwvZGl2Pic7DQpk
aXYuaW5uZXJIVE1MID0gY29udGVudDsNCjwvc2NyaXB0Pg0KPC9ib2R5PjwvaHRtbD4=
</data>

          </attachment>
      

    </bug>

</bugzilla>