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

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>14254</bug_id>
          
          <creation_ts>2011-09-22 21:19:49 +0000</creation_ts>
          <short_desc>insertText has to handle things like \r, \0, etc. sanely</short_desc>
          <delta_ts>2012-12-04 00:52:57 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebAppsWG</product>
          <component>HISTORICAL - HTML Editing APIs</component>
          <version>unspecified</version>
          <rep_platform>All</rep_platform>
          <op_sys>Windows 3.1</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>minor</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Aryeh Gregor">ayg</reporter>
          <assigned_to name="Aryeh Gregor">ayg</assigned_to>
          <cc>ehsan</cc>
    
    <cc>mike</cc>
    
    <cc>public-webapps</cc>
          
          <qa_contact name="HTML Editing APIs spec bugbot">sideshowbarker+html-editing-api</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>57187</commentid>
    <comment_count>0</comment_count>
    <who name="Aryeh Gregor">ayg</who>
    <bug_when>2011-09-22 21:19:49 +0000</bug_when>
    <thetext>What should happen if you do document.execCommand(&quot;inserttext&quot;, false, &quot;\0&quot;) or something like that?  That won&apos;t serialize to text/html.  Presumably the input needs to be sanitized somehow, but how?  The brute-force option is to say you have to apply a function that works like

  function normalizeText(text) {
    var span = document.createElement(&quot;span&quot;);
    span.textContent = text;
    span.innerHTML = span.innerHTML;
    return span.innerHTML;
  }

This will work, but is there a simpler way?  It would be pretty ridiculous to require calling the HTML parsing and serialization algorithms here.  I could just require that the results be the same, but that invites bugs.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>57222</commentid>
    <comment_count>1</comment_count>
    <who name="Simon Pieters">zcorpan</who>
    <bug_when>2011-09-23 08:26:12 +0000</bug_when>
    <thetext>The DOM can contain \r and \0 by using e.g. textContent. Why it it a problem for execCommand?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>57250</commentid>
    <comment_count>2</comment_count>
    <who name="Aryeh Gregor">ayg</who>
    <bug_when>2011-09-23 19:00:44 +0000</bug_when>
    <thetext>Hmm . . . good point.  I was aiming to only produce DOMs that serialize as text/html, but if the author is going to go out of their way to have scripts insert bogus stuff like this, no reason we should stand in their way.

In that case, I need to update gentest.html so it will generate these tests even though the DOM doesn&apos;t serialize.  Currently it assumes that such a test is buggy and skips generating it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>57253</commentid>
    <comment_count>3</comment_count>
    <who name="Ehsan Akhgari [:ehsan]">ehsan</who>
    <bug_when>2011-09-23 19:15:05 +0000</bug_when>
    <thetext>FWIW, what Gecko does is that it doesn&apos;t store \r&apos;s in the DOM, but it stores every other character as passed in.  And the only reason we handle \r&apos;s specially is to avoid the line-breaking hell across multiple platforms.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>