<?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>229597</bug_id>
          
          <creation_ts>2021-08-26 17:59:16 -0700</creation_ts>
          <short_desc>Content loss when copying or pasting lists with an empty first list item</short_desc>
          <delta_ts>2021-09-02 18:01:01 -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>HTML Editing</component>
          <version>Safari 14</version>
          <rep_platform>Mac (Intel)</rep_platform>
          <op_sys>macOS 11</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="James Toohey">james</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>megan_gardner</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>wenson_hsieh</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1787908</commentid>
    <comment_count>0</comment_count>
      <attachid>436596</attachid>
    <who name="James Toohey">james</who>
    <bug_when>2021-08-26 17:59:16 -0700</bug_when>
    <thetext>Created attachment 436596
A simple HTML file to replicate the bug

Hi team,

We discovered some cases where copying or pasting content in Safari 14 would cause content loss.

Context: Google Docs uses a `b` element to wrap their content with the document id when copying content e.g. `&lt;b id=&quot;docs-internal-guid-[uuid goes here]&quot;&gt;`. When creating a Google Doc with an empty line or empty list item as the first element, Safari converts this element into a style and strips other elements.

I have attached a very simple HTML reproduction case with the following example:

Input (clipboard content):
&lt;b data-important-attr=&quot;xyz&quot;&gt;
  &lt;ul&gt;
    &lt;li&gt;&lt;/li&gt;
    &lt;li&gt;text&lt;/li&gt;
  &lt;/ul&gt;
&lt;/b&gt;

Output (result from paste):
&lt;br&gt;
&lt;div&gt;
  &lt;span style=&quot;font-weight: bold;&quot;&gt;text&lt;/span&gt;
&lt;/div&gt;

Adding any content into the first list item results in the expected output:

Input (clipboard content):
&lt;b data-important-attr=&quot;xyz&quot;&gt;
  &lt;ul&gt;
    &lt;li&gt;text&lt;/li&gt;
    &lt;li&gt;text&lt;/li&gt;
  &lt;/ul&gt;
&lt;/b&gt;

Output (result from paste):
&lt;b data-important-attr=&quot;xyz&quot;&gt;
  &lt;ul&gt;
    &lt;li&gt;text&lt;/li&gt;
    &lt;li&gt;text&lt;/li&gt;
  &lt;/ul&gt;
&lt;/b&gt;

It is also worth noting that this occurs even without the wrapping `b` element:

Input (clipboard content):
&lt;ul&gt;
  &lt;li&gt;&lt;/li&gt;
  &lt;li&gt;text&lt;/li&gt;
&lt;/ul&gt;

Output (result from paste):
&lt;br&gt;
&lt;div&gt;text&lt;/div&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1790002</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2021-09-02 18:01:01 -0700</bug_when>
    <thetext>&lt;rdar://problem/82701564&gt;</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>436596</attachid>
            <date>2021-08-26 17:59:16 -0700</date>
            <delta_ts>2021-08-26 17:59:16 -0700</delta_ts>
            <desc>A simple HTML file to replicate the bug</desc>
            <filename>content_loss.html</filename>
            <type>text/html</type>
            <size>802</size>
            <attacher name="James Toohey">james</attacher>
            
              <data encoding="base64">PHA+UGxlYXNlIGNsaWNrIGFueXdoZXJlIGluIHRoZSBwYWdlLCBoaXQgQ01EL0NUUkwrQywgdGhl
biBw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