From 127edd1a1ea7c31f188c1416f129e61228acb237 Mon Sep 17 00:00:00 2001 From: "mats.palmgren@bredband.net" Date: Tue, 15 Jan 2008 02:22:58 -0800 Subject: [PATCH] Make NS_ReadLine() not lie about having more data when the stream ends in \r\n. b=397850 r+sr=cbiesinger a=blocking1.9 --- netwerk/base/public/nsReadLine.h | 118 ++++++++++------------ netwerk/test/unit/data/test_readline1.txt | 0 netwerk/test/unit/data/test_readline2.txt | 1 + netwerk/test/unit/data/test_readline3.txt | 3 + netwerk/test/unit/data/test_readline4.txt | 3 + netwerk/test/unit/data/test_readline5.txt | 1 + netwerk/test/unit/data/test_readline6.txt | 1 + netwerk/test/unit/data/test_readline7.txt | 2 + netwerk/test/unit/data/test_readline8.txt | 1 + netwerk/test/unit/test_readline.js | 94 +++++++++++++++++ 10 files changed, 159 insertions(+), 65 deletions(-) create mode 100644 netwerk/test/unit/data/test_readline1.txt create mode 100644 netwerk/test/unit/data/test_readline2.txt create mode 100644 netwerk/test/unit/data/test_readline3.txt create mode 100644 netwerk/test/unit/data/test_readline4.txt create mode 100644 netwerk/test/unit/data/test_readline5.txt create mode 100644 netwerk/test/unit/data/test_readline6.txt create mode 100644 netwerk/test/unit/data/test_readline7.txt create mode 100644 netwerk/test/unit/data/test_readline8.txt create mode 100644 netwerk/test/unit/test_readline.js diff --git a/netwerk/base/public/nsReadLine.h b/netwerk/base/public/nsReadLine.h index fb6d7a94349..06eac4a9eda 100644 --- a/netwerk/base/public/nsReadLine.h +++ b/netwerk/base/public/nsReadLine.h @@ -22,6 +22,7 @@ * * Contributor(s): * Christian Biesinger + * Mats Palmgren * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or @@ -60,21 +61,23 @@ * Buffer size. This many bytes will be buffered. If a line is longer than this, * the partial line will be appended to the out parameter of NS_ReadLine and the * buffer will be emptied. + * Note: if you change this constant, please update the regression test in + * netwerk/test/unit/test_readline.js accordingly (bug 397850). */ #define kLineBufferSize 4096 /** * @internal * Line buffer structure, buffers data from an input stream. + * The buffer is empty when |start| == |end|. + * Invariant: |start| <= |end| */ template class nsLineBuffer { public: CharT buf[kLineBufferSize+1]; CharT* start; - CharT* current; CharT* end; - PRBool empty; }; /** @@ -105,8 +108,7 @@ NS_InitLineBuffer (nsLineBuffer ** aBufferPtr) { if (!(*aBufferPtr)) return NS_ERROR_OUT_OF_MEMORY; - (*aBufferPtr)->start = (*aBufferPtr)->current = (*aBufferPtr)->end = (*aBufferPtr)->buf; - (*aBufferPtr)->empty = PR_TRUE; + (*aBufferPtr)->start = (*aBufferPtr)->end = (*aBufferPtr)->buf; return NS_OK; } @@ -136,76 +138,62 @@ NS_InitLineBuffer (nsLineBuffer ** aBufferPtr) { template nsresult NS_ReadLine (StreamType* aStream, nsLineBuffer * aBuffer, - StringType & aLine, PRBool *more) { - nsresult rv = NS_OK; - PRUint32 bytesRead; - *more = PR_TRUE; - PRBool eolStarted = PR_FALSE; - CharT eolchar = '\0'; + StringType & aLine, PRBool *more) +{ + CharT eolchar = 0; // the first eol char or 1 after \r\n or \n\r is found + aLine.Truncate(); + while (1) { // will be returning out of this loop on eol or eof - if (aBuffer->empty) { // buffer is empty. Read into it. - rv = aStream->Read(aBuffer->buf, kLineBufferSize, &bytesRead); - if (NS_FAILED(rv)) // read failed - return rv; - if (bytesRead == 0) { // end of file + if (aBuffer->start == aBuffer->end) { // buffer is empty. Read into it. + PRUint32 bytesRead; + nsresult rv = aStream->Read(aBuffer->buf, kLineBufferSize, &bytesRead); + if (NS_FAILED(rv) || NS_UNLIKELY(bytesRead == 0)) { *more = PR_FALSE; - return NS_OK; + return rv; } + aBuffer->start = aBuffer->buf; aBuffer->end = aBuffer->buf + bytesRead; - aBuffer->empty = PR_FALSE; - *(aBuffer->end) = '\0'; // null-terminate this thing + *(aBuffer->end) = '\0'; } - // walk the buffer looking for an end-of-line - while (aBuffer->current < aBuffer->end) { - if (eolStarted) { - if ((eolchar == '\n' && *(aBuffer->current) == '\r') || - (eolchar == '\r' && *(aBuffer->current) == '\n')) { // line end - (aBuffer->current)++; - aBuffer->start = aBuffer->current; - } - eolStarted = PR_FALSE; - return NS_OK; - } else if (*(aBuffer->current) == '\n' || - *(aBuffer->current) == '\r') { // line end - eolStarted = PR_TRUE; - eolchar = *(aBuffer->current); - *(aBuffer->current) = '\0'; - aLine.Append(aBuffer->start); - (aBuffer->current)++; - aBuffer->start = aBuffer->current; - } else { - eolStarted = PR_FALSE; - (aBuffer->current)++; + + /* + * Walk the buffer looking for an end-of-line. + * There are 3 cases to consider: + * 1. the eol char is the last char in the buffer + * 2. the eol char + one more char at the end of the buffer + * 3. the eol char + two or more chars at the end of the buffer + * we need at least one char after the first eol char to determine if + * it's a \r\n or \n\r sequence (and skip over it), and we need one + * more char after the end-of-line to set |more| correctly. + */ + CharT* current = aBuffer->start; + if (NS_LIKELY(eolchar == 0)) { + for ( ; current < aBuffer->end; ++current) { + if (*current == '\n' || *current == '\r') { + eolchar = *current; + *current++ = '\0'; + aLine.Append(aBuffer->start); + break; + } + } + } + if (NS_LIKELY(eolchar != 0)) { + for ( ; current < aBuffer->end; ++current) { + if ((eolchar == '\r' && *current == '\n') || + (eolchar == '\n' && *current == '\r')) { + eolchar = 1; + continue; + } + aBuffer->start = current; + *more = PR_TRUE; + return NS_OK; } } - // append whatever we currently have to the string - aLine.Append(aBuffer->start); - - // we've run out of buffer. Begin anew - aBuffer->current = aBuffer->start = aBuffer->buf; - aBuffer->empty = PR_TRUE; - - if (eolStarted) { // have to read another char and possibly skip over it - rv = aStream->Read(aBuffer->buf, 1, &bytesRead); - if (NS_FAILED(rv)) // read failed - return rv; - if (bytesRead == 0) { // end of file - *more = PR_FALSE; - return NS_OK; - } - if ((eolchar == '\n' && *(aBuffer->buf) == '\r') || - (eolchar == '\r' && *(aBuffer->buf) == '\n')) { - // Just return and all is good -- we've skipped the extra newline char - return NS_OK; - } else { - // we have a byte that we should look at later - aBuffer->empty = PR_FALSE; - aBuffer->end = aBuffer->buf + 1; - *(aBuffer->end) = '\0'; - } - } + if (eolchar == 0) + aLine.Append(aBuffer->start); + aBuffer->start = aBuffer->end; // mark the buffer empty } } diff --git a/netwerk/test/unit/data/test_readline1.txt b/netwerk/test/unit/data/test_readline1.txt new file mode 100644 index 00000000000..e69de29bb2d diff --git a/netwerk/test/unit/data/test_readline2.txt b/netwerk/test/unit/data/test_readline2.txt new file mode 100644 index 00000000000..67c32976114 --- /dev/null +++ b/netwerk/test/unit/data/test_readline2.txt @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/netwerk/test/unit/data/test_readline3.txt b/netwerk/test/unit/data/test_readline3.txt new file mode 100644 index 00000000000..decdc518783 --- /dev/null +++ b/netwerk/test/unit/data/test_readline3.txt @@ -0,0 +1,3 @@ + + + diff --git a/netwerk/test/unit/data/test_readline4.txt b/netwerk/test/unit/data/test_readline4.txt new file mode 100644 index 00000000000..ca25c365405 --- /dev/null +++ b/netwerk/test/unit/data/test_readline4.txt @@ -0,0 +1,3 @@ +1 + 23 456 +78901 diff --git a/netwerk/test/unit/data/test_readline5.txt b/netwerk/test/unit/data/test_readline5.txt new file mode 100644 index 00000000000..8463b7858e5 --- /dev/null +++ b/netwerk/test/unit/data/test_readline5.txt @@ -0,0 +1 @@ +xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx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xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxE \ No newline at end of file diff --git a/netwerk/test/unit/data/test_readline6.txt b/netwerk/test/unit/data/test_readline6.txt new file mode 100644 index 00000000000..872c40afc48 --- /dev/null +++ b/netwerk/test/unit/data/test_readline6.txt @@ -0,0 +1 @@ +xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx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xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxE diff --git a/netwerk/test/unit/data/test_readline7.txt b/netwerk/test/unit/data/test_readline7.txt new file mode 100644 index 00000000000..59ee122ce1e --- /dev/null +++ b/netwerk/test/unit/data/test_readline7.txt @@ -0,0 +1,2 @@ +xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx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xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxE + \ No newline at end of file diff --git a/netwerk/test/unit/data/test_readline8.txt b/netwerk/test/unit/data/test_readline8.txt new file mode 100644 index 00000000000..ff6fc09a4aa --- /dev/null +++ b/netwerk/test/unit/data/test_readline8.txt @@ -0,0 +1 @@ +zzzzzzzzzz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ff --git a/netwerk/test/unit/test_readline.js b/netwerk/test/unit/test_readline.js new file mode 100644 index 00000000000..d7fed84eb94 --- /dev/null +++ b/netwerk/test/unit/test_readline.js @@ -0,0 +1,94 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is Mats Palmgren. + * Portions created by the Initial Developer are Copyright (C) 2007 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Mats Palmgren + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +const Cc = Components.classes; +const Ci = Components.interfaces; +const PR_RDONLY = 0x1; + +function new_file_input_stream(file) { + var stream = + Cc["@mozilla.org/network/file-input-stream;1"] + .createInstance(Ci.nsIFileInputStream); + stream.init(file, PR_RDONLY, 0, 0); + return stream; +} + +function new_line_input_stream(filename) { + return new_file_input_stream(do_get_file(filename)) + .QueryInterface(Ci.nsILineInputStream); +} + +var test_array = [ + { file:"netwerk/test/unit/data/test_readline1.txt", lines:[] }, + { file:"netwerk/test/unit/data/test_readline2.txt", lines:[""] }, + { file:"netwerk/test/unit/data/test_readline3.txt", lines:["","","","",""] }, + { file:"netwerk/test/unit/data/test_readline4.txt", lines:["1","23","456","","78901"] }, + { file:"netwerk/test/unit/data/test_readline5.txt", lines:["xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx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xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxE"] }, +]; + +function err(file, lineNo, msg) { + do_throw("\""+file+"\" line "+lineNo+", "+msg); +} + +function run_test() +{ + for each (var test in test_array) { + var lineStream = new_line_input_stream(test.file); + var lineNo = 0; + var more = false; + var line = {}; + more = lineStream.readLine(line); + for each (var check in test.lines) { + ++lineNo; + if (lineNo == test.lines.length) { + if (more) err(test.file, lineNo, "There should be no more data after the last line"); + } + else { + if (!more) err(test.file, lineNo, "There should be more data after this line"); + } + if (line.value != check) + err(test.file, lineNo, "Wrong value, got '"+line.value+"' expected '"+check+"'"); + dump("ok \""+test.file+"\" line "+lineNo+" (length "+line.value.length+"): '"+line.value+"'\n"); + more = lineStream.readLine(line); + } + if (more) err(test.file, lineNo, "'more' should be false after reading all lines"); + dump("ok \""+test.file+"\" succeeded\n"); + lineStream.close(); + } +}