Bug 15415

Summary: parse the end of line about the FTPDIR list error!
Product: WebKit Reporter: wesleyZeng <weihong.zeng>
Component: Page LoadingAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: beidson, webkit
Priority: P2    
Version: 523.x (Safari 3)   
Hardware: PC   
OS: OS X 10.4   
Attachments:
Description Flags
fix ftpdir beidson: review-

Description wesleyZeng 2007-10-07 20:11:34 PDT
Split ftp list with '\n', but the variable foundNewLine(loader/FTPDirectoryDocument.cpp:389) is setted when the current character is '\r'. 
    See details about diffs:

Index: FTPDirectoryDocument.cpp
===================================================================
--- FTPDirectoryDocument.cpp    £¨ÐÞ¶©°æ 26103£©
+++ FTPDirectoryDocument.cpp    £¨¹¤×÷¿½±´£©
@@ -386,7 +386,6 @@

         if (c == '\r') {
             *m_dest++ = '\n';
-            foundNewLine = true;
             // possibly skip an LF in the case of an CRLF sequence
             m_skipLF = true;
         } else if (c == '\n') {
@@ -394,6 +393,7 @@
                 *m_dest++ = c;
             else
                 m_skipLF = false;
+            foundNewLine = true;
         } else {
             *m_dest++ = c;
             m_skipLF = false;
Comment 1 Robert Blaut 2008-03-17 07:05:46 PDT
(In reply to comment #0)
> Split ftp list with '\n', but the variable
> foundNewLine(loader/FTPDirectoryDocument.cpp:389) is setted when the current
> character is '\r'. 
>     See details about diffs:

Can someone proceed with this report, please? 

wesleyZeng, did you see live example (URL) that the reported issue caused problems?
Comment 2 wesleyZeng 2008-03-17 21:10:59 PDT
'\n' is the end of line(EOL) on Linux , "\r\n" is EOL on Win32, and '\r' is EOL on Mac.

So, if the current character is '\r' , m_skipLF is setted; 
if the current character is '\n', foundNewLine should be setted; 

e.g
ftp://ftp.mozilla.org/pub
Comment 3 wesleyZeng 2008-03-17 21:52:51 PDT
Created attachment 19859 [details]
fix ftpdir
Comment 4 Brady Eidson 2008-03-18 09:52:00 PDT
Comment on attachment 19859 [details]
fix ftpdir

This was a good find, but I think the fix is wrong for this reason:
We treat any of the sequences - /r, /r/n, and /n - as newlines.  foundNewLine should be set whenever we encounter *any* of these sequences.  I think moving the foundNewLine assignment isn't right, but adding the new one is (so we have it in both places)
Comment 5 Brady Eidson 2008-03-18 09:52:54 PDT
On the note of bug fixes coming in to this code, we really need to get the layout tests augmented to regression test it  =/