<?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>15961</bug_id>
          
          <creation_ts>2007-11-12 16:11:01 -0800</creation_ts>
          <short_desc>View source mode is missing the processing instruction line.</short_desc>
          <delta_ts>2013-01-02 12:49:54 -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>Web Inspector (Deprecated)</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>HasReduction, InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Anyang Ren">anyang.ren</reporter>
          <assigned_to name="Elliott Sprehn">esprehn</assigned_to>
          <cc>ap</cc>
    
    <cc>esprehn</cc>
    
    <cc>hyatt</cc>
    
    <cc>webkit.review.bot</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>61032</commentid>
    <comment_count>0</comment_count>
    <who name="Anyang Ren">anyang.ren</who>
    <bug_when>2007-11-12 16:11:01 -0800</bug_when>
    <thetext>In the view source mode, the processing instruction line is missing in the output.

For example, the first line of the HTML page at http://alioth.debian.org/ is
a processing instruction:
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;

This line is missing in the view source mode output.  I tracked it down to the
HTMLTokenizer class, specifically the HTMLTokenizer::write and
HTMLTokenizer::parseProcessingInstruction methods.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>61035</commentid>
    <comment_count>1</comment_count>
      <attachid>17217</attachid>
    <who name="Anyang Ren">anyang.ren</who>
    <bug_when>2007-11-12 16:31:39 -0800</bug_when>
    <thetext>Created attachment 17217
Preliminary patch for discussion

This patch is intended to show where the problem is, even though
it is in the form of a fix.  I hope that the WebKit team can come up
with a better fix.

In HTMLTokenizer::write, after the call to parseProcessingInstruction
returns, we continue the while loop.  So we skip the processToken call
at the end of the switch statement, and the line is not added to the
HTMLViewSourceDocument by the addViewSourceToken call in
HTMLTokenizer::processToken.

I first tried removing the &quot;continue&quot; statement so that we fall through to
the processToken call after the switch statement.  But the parseTag call
after the processToken call caused an empty &quot;&lt;&gt;&quot; tag to be added after
the processing instruction line.  So I&apos;m now calling processToken before
the continue statement.

The other changes in this patch add the characters of the processing
instruction line to &apos;buffer&apos; (via the &apos;dest&apos; pointer) so that they show up
in the output.  It is also necessary to remove the state.setDiscardLF(true)
statement so that we don&apos;t lose the LF after the processing instruction line
in the output.

Note that I mark the processing instruction line as a textAtom simply because
it is easier to work with HTMLTokenizer::processToken and
HTMLViewSourceDocument::addViewSourceToken to output a textAtom.
I believe the processing instruction line should be handled as a tag.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>61113</commentid>
    <comment_count>2</comment_count>
    <who name="Anyang Ren">anyang.ren</who>
    <bug_when>2007-11-13 13:28:47 -0800</bug_when>
    <thetext>David, I&apos;d appreciate your comments on this view source mode
bug and the right way to fix it.  Thanks.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>61155</commentid>
    <comment_count>3</comment_count>
    <who name="David Kilzer (:ddkilzer)">ddkilzer</who>
    <bug_when>2007-11-13 20:32:23 -0800</bug_when>
    <thetext>Viewing the source of http://alioth.debian.org/ from Safari 3 Public Beta with a local debug build of WebKit r27716 on Tiger shows the &lt;?xml...&gt; tag for me.

Which Safari/WebKit are you seeing this on?

Please set the &quot;review?&quot; flag if you want the patch reviewed for comments.

</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>61223</commentid>
    <comment_count>4</comment_count>
      <attachid>17217</attachid>
    <who name="Anyang Ren">anyang.ren</who>
    <bug_when>2007-11-14 11:42:09 -0800</bug_when>
    <thetext>Comment on attachment 17217
Preliminary patch for discussion

I&apos;m using WebKit/WebCore/html/HTMLTokenizer.cpp, r25754.
I&apos;m not using Safari.  Safari&apos;s &quot;View Source&quot; command doesn&apos;t seem to be
implemented using the &quot;view source mode&quot; of the HTMLTokenizer class.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>61244</commentid>
    <comment_count>5</comment_count>
    <who name="Anyang Ren">anyang.ren</who>
    <bug_when>2007-11-14 14:40:51 -0800</bug_when>
    <thetext>(In reply to comment #3)
&gt; Viewing the source of http://alioth.debian.org/ from Safari 3 Public Beta with
&gt; a local debug build of WebKit r27716 on Tiger shows the &lt;?xml...&gt; tag for me.

You can confirm this bug using the Source view in the Web Inspector.

</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>62051</commentid>
    <comment_count>6</comment_count>
      <attachid>17217</attachid>
    <who name="Maciej Stachowiak">mjs</who>
    <bug_when>2007-11-22 23:00:45 -0800</bug_when>
    <thetext>Comment on attachment 17217
Preliminary patch for discussion

I&apos;m not 100% sure if this change is right, it seems generally ok.

However, it needs a ChangeLog and a layout test. You can force view source mode by putting the relevant contents into an &lt;iframe&gt; element with the viewsource attribute set.

r- for lack of test case and ChangeLog.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>67258</commentid>
    <comment_count>7</comment_count>
      <attachid>18449</attachid>
    <who name="Eric Seidel (no email)">eric</who>
    <bug_when>2008-01-14 15:38:28 -0800</bug_when>
    <thetext>Created attachment 18449
test case

Here is a test case which I believe demonstrates the bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>68636</commentid>
    <comment_count>8</comment_count>
    <who name="Adam Roben (:aroben)">aroben</who>
    <bug_when>2008-01-29 11:04:07 -0800</bug_when>
    <thetext>&lt;rdar://problem/5712854&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>695806</commentid>
    <comment_count>9</comment_count>
    <who name="Elliott Sprehn">esprehn</who>
    <bug_when>2012-08-15 00:38:53 -0700</bug_when>
    <thetext>This is actually fixed, probably by the HTML5 parser rewrite. We should just add a layout test and close this bug.

(Note the patch here is impossible to apply as well since HTMLTokenizer has been entirely rewritten.)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>798800</commentid>
    <comment_count>10</comment_count>
      <attachid>181046</attachid>
    <who name="Elliott Sprehn">esprehn</who>
    <bug_when>2013-01-02 12:27:03 -0800</bug_when>
    <thetext>Created attachment 181046
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>798819</commentid>
    <comment_count>11</comment_count>
      <attachid>181046</attachid>
    <who name="WebKit Review Bot">webkit.review.bot</who>
    <bug_when>2013-01-02 12:49:50 -0800</bug_when>
    <thetext>Comment on attachment 181046
Patch

Clearing flags on attachment: 181046

Committed r138637: &lt;http://trac.webkit.org/changeset/138637&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>798821</commentid>
    <comment_count>12</comment_count>
    <who name="WebKit Review Bot">webkit.review.bot</who>
    <bug_when>2013-01-02 12:49:54 -0800</bug_when>
    <thetext>All reviewed patches have been landed.  Closing bug.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="1"
              ispatch="1"
              isprivate="0"
          >
            <attachid>17217</attachid>
            <date>2007-11-12 16:31:39 -0800</date>
            <delta_ts>2013-01-02 12:27:02 -0800</delta_ts>
            <desc>Preliminary patch for discussion</desc>
            <filename>HTMLTokenizer.txt</filename>
            <type>text/plain</type>
            <size>2085</size>
            <attacher name="Anyang Ren">anyang.ren</attacher>
            
              <data encoding="base64">LS0tIEhUTUxUb2tlbml6ZXIuY3BwLm9yaWcJMjAwNy0xMS0xMiAxNjowMTo0Mi41MzA5OTM4MDAg
LTA4MDAKKysrIEhUTUxUb2tlbml6ZXIuY3BwCTIwMDctMTEtM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mFs
c2UpOwogICAgICAgICAgICAgc3JjLmFkdmFuY2UobGluZU51bWJlclB0cigpKTsKLSAgICAgICAg
ICAgIHN0YXRlLnNldERpc2NhcmRMRih0cnVlKTsKKyAgICAgICAgICAgIC8vc3RhdGUuc2V0RGlz
Y2FyZExGKHRydWUpOworICAgICAgICAgICAgY3VyclRva2VuLnRhZ05hbWUgPSB0ZXh0QXRvbTsK
ICAgICAgICAgICAgIHJldHVybiBzdGF0ZTsgLy8gRmluaXNoZWQgcGFyc2luZyBjb21tZW50IQog
ICAgICAgICB9CiAgICAgICAgIHNyYy5hZHZhbmNlKGxpbmVOdW1iZXJQdHIoKSk7CiAgICAgICAg
IG9sZGNoYXIgPSBjaGJlZ2luOwogICAgIH0KICAgICAKICAgICByZXR1cm4gc3RhdGU7CiB9CkBA
IC0xNDA4LDE5ICsxNDExLDIxIEBACiAgICAgICAgICAgICAgICAgY2FzZSAnISc6IHsKICAgICAg
ICAgICAgICAgICAgICAgLy8gPCEtLSBjb21tZW50IC0tPgogICAgICAgICAgICAgICAgICAgICBz
ZWFyY2hDb3VudCA9IDE7IC8vIExvb2sgZm9yICc8IS0tJyBzZXF1ZW5jZSB0byBzdGFydCBjb21t
ZW50CiAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICBicmVhazsKICAg
ICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgY2FzZSAnPyc6IHsKICAgICAgICAgICAg
ICAgICAgICAgLy8geG1sIHByb2Nlc3NpbmcgaW5zdHJ1Y3Rpb24KKyAgICAgICAgICAgICAgICAg
ICAgKmRlc3QrKyA9ICc8JzsKICAgICAgICAgICAgICAgICAgICAgc3RhdGUuc2V0SW5Qcm9jZXNz
aW5nSW5zdHJ1Y3Rpb24odHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgIHRxdW90ZSA9IE5vUXVv
dGU7CiAgICAgICAgICAgICAgICAgICAgIHN0YXRlID0gcGFyc2VQcm9jZXNzaW5nSW5zdHJ1Y3Rp
b24oc3JjLCBzdGF0ZSk7CisgICAgICAgICAgICAgICAgICAgIHByb2Nlc3NUb2tlbigpOwogICAg
ICAgICAgICAgICAgICAgICBjb250aW51ZTsKIAogICAgICAgICAgICAgICAgICAgICBicmVhazsK
ICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgY2FzZSAnJSc6CiAgICAgICAgICAg
ICAgICAgICAgIGlmICghYnJva2VuU2VydmVyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAv
LyA8JSBzZXJ2ZXIgc3R1ZmYsIGhhbmRsZSBhcyBjb21tZW50ICU+CiAgICAgICAgICAgICAgICAg
ICAgICAgICBzdGF0ZS5zZXRJblNlcnZlcih0cnVlKTsK
</data>

          </attachment>
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>18449</attachid>
            <date>2008-01-14 15:38:28 -0800</date>
            <delta_ts>2008-01-14 15:38:28 -0800</delta_ts>
            <desc>test case</desc>
            <filename>viewsource.html</filename>
            <type>text/html</type>
            <size>185</size>
            <attacher name="Eric Seidel (no email)">eric</attacher>
            
              <data encoding="base64">PGlmcmFtZSB2aWV3c291cmNlIHNyYz0iZGF0YTp0ZXh0L2h0bWw7YmFzZTY0LFBEOTRiV3dnZG1W
eWMybHZiajFjWEZ3aU1TNHdYRnhjSWlCbGJtTnZaR2x1WnoxY1hGd2lWVlJHTFRoY1hGd2lQejRO
Q2p4b2RHMXNQZzBLUEdKdlpIaytEUW84Y0Q1R1QwODhMM0ErRFFvOEwySnZaSGsrRFFvOGFIUnRi
RDQ9Ij48L2lmcmFtZT4=
</data>

          </attachment>
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>181046</attachid>
            <date>2013-01-02 12:27:03 -0800</date>
            <delta_ts>2013-01-02 12:49:50 -0800</delta_ts>
            <desc>Patch</desc>
            <filename>bug-15961-20130102122411.patch</filename>
            <type>text/plain</type>
            <size>1882</size>
            <attacher name="Elliott Spr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