Steven Brown

Jaxer Bug: Jaxer.File.readline Not Detecting Line Endings Correctly

by on Dec.26, 2008, under Jaxer

Jaxer.File.readline does not correctly detect Windows line endings (\r\n). Instead it will detect this as two lines, one ending in \r and one ending in \n.

When calling Jaxer.File.readline on a file with line endings of “\r\n”, such as the following:

some text here\r\n
some more text

Using the following code:

var content = '';
while (inLine = file.readline())
{
    content += inLine + '\r\n';
}

The above code will stop at “some text here” and the next result will be blank. This is because the first call to readline gets “some text here\r” and the next gets “\n”.

On line 1410 of JSLib.js is this:

this._lineBuffer = buf.split(/[\r\n]/);

It should actually be:

this._lineBuffer = buf.split(/(\r\n|\r|\n)/);

This new code will correctly detect Windows newlines (\r\n) as well as Linux (\n) and Mac (\r) newlines.

Follow this bug at http://support.aptana.com/asap/browse/JXR-421


Leave a Reply

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!