<?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>184604</bug_id>
          
          <creation_ts>2018-04-13 14:57:36 -0700</creation_ts>
          <short_desc>Correct serialization of Selectors</short_desc>
          <delta_ts>2023-08-26 00:15:58 -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>CSS</component>
          <version>Safari 11</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          <see_also>https://github.com/w3c/csswg-drafts/issues/8911</see_also>
    
    <see_also>https://github.com/w3c/csswg-drafts/issues/8909</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>BrowserCompat, InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          <dependson>257741</dependson>
          
          <everconfirmed>1</everconfirmed>
          <reporter>pascal</reporter>
          <assigned_to name="Anne van Kesteren">annevk</assigned_to>
          <cc>ahmad.saleem792</cc>
    
    <cc>annevk</cc>
    
    <cc>bfulgham</cc>
    
    <cc>cdumez</cc>
    
    <cc>karlcow</cc>
    
    <cc>koivisto</cc>
    
    <cc>ntim</cc>
    
    <cc>simon.fraser</cc>
    
    <cc>vojacem</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1414517</commentid>
    <comment_count>0</comment_count>
      <attachid>337924</attachid>
    <who name="">pascal</who>
    <bug_when>2018-04-13 14:57:36 -0700</bug_when>
    <thetext>Created attachment 337924
Simple reproduction

Given a custom tag name with a colon in it (e.g. foo\:bar { font-weight; bold }), the cssText property should return a properly escaped string.

Instead, the backslash gets dropped. Attached a simple example; in Chrome and Firefox pressing the button has no visible effect, in Safari the text changes color.

This is potentially a regression:

https://bugs.webkit.org/show_bug.cgi?id=33725
https://bugs.webkit.org/show_bug.cgi?id=34529</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1414520</commentid>
    <comment_count>1</comment_count>
    <who name="">pascal</who>
    <bug_when>2018-04-13 15:08:29 -0700</bug_when>
    <thetext>Note, this also happens for other parts of the selector string, for example property names:

[ng\:cloak] { display: none; }</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1884190</commentid>
    <comment_count>2</comment_count>
    <who name="Brent Fulgham">bfulgham</who>
    <bug_when>2022-07-15 13:56:11 -0700</bug_when>
    <thetext>This continues to be an issue in Safari 15.5+.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1884191</commentid>
    <comment_count>3</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2022-07-15 13:56:23 -0700</bug_when>
    <thetext>&lt;rdar://problem/97092572&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1958530</commentid>
    <comment_count>4</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2023-05-28 09:38:29 -0700</bug_when>
    <thetext>Still issue in Webkit ToT (264635@main).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1959553</commentid>
    <comment_count>5</comment_count>
    <who name="Anne van Kesteren">annevk</who>
    <bug_when>2023-06-02 09:17:08 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/14629</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1959579</commentid>
    <comment_count>6</comment_count>
    <who name="Anne van Kesteren">annevk</who>
    <bug_when>2023-06-02 10:57:30 -0700</bug_when>
    <thetext>I filed https://github.com/w3c/csswg-drafts/issues/8909 against the specification. Looking at this more it seems this problem also applies to attributes. I&apos;m somewhat surprised it was not discovered before.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1959675</commentid>
    <comment_count>7</comment_count>
    <who name="Anne van Kesteren">annevk</who>
    <bug_when>2023-06-03 00:07:12 -0700</bug_when>
    <thetext>I think there&apos;s two bugs at issue here:

1. Selector serialization. We emit the raw identifier rather than the escaped identifier as required by https://drafts.csswg.org/cssom/#serialize-a-simple-selector.
2. Selector representation. For both the prefix and local name we don&apos;t represent the universal selector as its own thing internally. We therefore cannot distinguish between the inputs * and \*. Chromium has this problem as well, but only for the prefix.

You can kinda fix 1 by serializing a lone * as * and not \*, but that still leaves

  \* { color:red }

doing the wrong thing and also incorrectly getting serialized as

  * { color:red }

The next step here is probably writing web-platform-tests as there appears to be no coverage for these scenarios in css/selectors or anywhere in WebKit&apos;s own tests based on my naive fix for 1.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1959695</commentid>
    <comment_count>8</comment_count>
    <who name="Anne van Kesteren">annevk</who>
    <bug_when>2023-06-03 07:22:48 -0700</bug_when>
    <thetext>I convinced myself that 1 might not be so desirable after all given how the DOM works. Seems easier to just special case * in a couple of places. I opened https://github.com/w3c/csswg-drafts/issues/8911 to discuss this further and depending on the outcome of that our model will either be validated or we&apos;ll have to create some kind of internal representation for *, but I hope not.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1960524</commentid>
    <comment_count>9</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2023-06-08 03:45:25 -0700</bug_when>
    <thetext>Committed 264980@main (892935d504cf): &lt;https://commits.webkit.org/264980@main&gt;

Reviewed commits have been landed. Closing PR #14629 and removing active labels.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1973753</commentid>
    <comment_count>10</comment_count>
    <who name="Anne van Kesteren">annevk</who>
    <bug_when>2023-08-26 00:15:58 -0700</bug_when>
    <thetext>*** Bug 253041 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>337924</attachid>
            <date>2018-04-13 14:57:36 -0700</date>
            <delta_ts>2018-04-13 14:57:36 -0700</delta_ts>
            <desc>Simple reproduction</desc>
            <filename>test.html</filename>
            <type>text/html</type>
            <size>585</size>
            <attacher>pascal</attacher>
            
              <data encoding="base64">PCFkb2N0eXBlIGh0bWw+CjxodG1sIGxhbmc9ImVuIj4KPGhlYWQ+CiAgPG1ldGEgY2hhcnNldD0i
VVRGLTgiPgogIDx0aXRsZT5UZXN0PC90aXRsZT4KPC9oZWFkPgo8c3R5bGUgaWQ9InRlc3QiPgog
IHBcOmZvbyB7CiAgICBjb2xvcjogcmVkOwogIH0KPC9zdHlsZT4KPC9zdHlsZT4KPGJvZHk+CiAg
PHA6Zm9vPlRoaXMgaXMgcmVkLjwvcDpmb28+CiAgPGJ1dHRvbiBpZD0icnVuIj5SZXBsYWNlIHdp
dGggY3NzVGV4dDwvYnV0dG9uPgoKICA8c2NyaXB0PgogIGRvY3VtZW50LmdldEVsZW1lbnRCeUlk
KCdydW4nKS5vbmNsaWNrID0gKCkgPT4gewogICAgY29uc3Qgbm9kZSA9IGRvY3VtZW50LmdldEVs
ZW1lbnRCeUlkKCd0ZXN0Jyk7CgogICAgbGV0IGNvbnRlbnRzID0gJyc7CiAgICBmb3IgKGxldCBp
ID0gMDsgaSA8IG5vZGUuc2hlZXQucnVsZXMubGVuZ3RoOyBpKyspIHsKICAgICAgY29udGVudHMg
Kz0gbm9kZS5zaGVldC5ydWxlc1tpXS5jc3NUZXh0OwogICAgfQoKICAgIGNvbnNvbGUubG9nKGNv
bnRlbnRzKTsKCiAgICBub2RlLmlubmVyVGV4dCA9IGNvbnRlbnRzOwogIH0KICA8L3NjcmlwdD4K
PC9ib2R5Pgo8L2h0bWw+
</data>

          </attachment>
      

    </bug>

</bugzilla>