import FIREFOX_52_6_0esr_RELEASE from mozilla-esr52 hg repo

This commit is contained in:
Roy Tam 2018-01-19 03:59:58 +08:00
commit dcd9973243
150858 changed files with 23884658 additions and 0 deletions

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,104 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef ParseRTPList_h___
#define ParseRTPList_h___
#include <stdint.h>
#include <string.h>
#include "prtime.h"
/* ParseFTPList() parses lines from an FTP LIST command.
**
** Written July 2002 by Cyrus Patel <cyp@fb14.uni-mainz.de>
** with acknowledgements to squid, lynx, wget and ftpmirror.
**
** Arguments:
** 'line': line of FTP data connection output. The line is assumed
** to end at the first '\0' or '\n' or '\r\n'.
** 'state': a structure used internally to track state between
** lines. Needs to be bzero()'d at LIST begin.
** 'result': where ParseFTPList will store the results of the parse
** if 'line' is not a comment and is not junk.
**
** Returns one of the following:
** 'd' - LIST line is a directory entry ('result' is valid)
** 'f' - LIST line is a file's entry ('result' is valid)
** 'l' - LIST line is a symlink's entry ('result' is valid)
** '?' - LIST line is junk. (cwd, non-file/dir/link, etc)
** '"' - its not a LIST line (its a "comment")
**
** It may be advisable to let the end-user see "comments" (particularly when
** the listing results in ONLY such lines) because such a listing may be:
** - an unknown LIST format (NLST or "custom" format for example)
** - an error msg (EPERM,ENOENT,ENFILE,EMFILE,ENOTDIR,ENOTBLK,EEXDEV etc).
** - an empty directory and the 'comment' is a "total 0" line or similar.
** (warning: a "total 0" can also mean the total size is unknown).
**
** ParseFTPList() supports all known FTP LISTing formats:
** - '/bin/ls -l' and all variants (including Hellsoft FTP for NetWare);
** - EPLF (Easily Parsable List Format);
** - Windows NT's default "DOS-dirstyle";
** - OS/2 basic server format LIST format;
** - VMS (MultiNet, UCX, and CMU) LIST format (including multi-line format);
** - IBM VM/CMS, VM/ESA LIST format (two known variants);
** - SuperTCP FTP Server for Win16 LIST format;
** - NetManage Chameleon (NEWT) for Win16 LIST format;
** - '/bin/dls' (two known variants, plus multi-line) LIST format;
** If there are others, then I'd like to hear about them (send me a sample).
**
** NLSTings are not supported explicitely because they cannot be machine
** parsed consistently: NLSTings do not have unique characteristics - even
** the assumption that there won't be whitespace on the line does not hold
** because some nlistings have more than one filename per line and/or
** may have filenames that have spaces in them. Moreover, distinguishing
** between an error message and an NLST line would require ParseList() to
** recognize all the possible strerror() messages in the world.
*/
/* #undef anything you don't want to support */
#define SUPPORT_LSL /* /bin/ls -l and dozens of variations therof */
#define SUPPORT_DLS /* /bin/dls format (very, Very, VERY rare) */
#define SUPPORT_EPLF /* Extraordinarily Pathetic List Format */
#define SUPPORT_DOS /* WinNT server in 'site dirstyle' dos */
#define SUPPORT_VMS /* VMS (all: MultiNet, UCX, CMU-IP) */
#define SUPPORT_CMS /* IBM VM/CMS,VM/ESA (z/VM and LISTING forms) */
#define SUPPORT_OS2 /* IBM TCP/IP for OS/2 - FTP Server */
#define SUPPORT_W16 /* win16 hosts: SuperTCP or NetManage Chameleon */
struct list_state
{
list_state() {
memset(this, 0, sizeof(*this));
}
PRTime now_time; /* needed for year determination */
PRExplodedTime now_tm; /* needed for year determination */
int32_t lstyle; /* LISTing style */
int32_t parsed_one; /* returned anything yet? */
char carry_buf[84]; /* for VMS multiline */
uint32_t carry_buf_len; /* length of name in carry_buf */
uint32_t numlines; /* number of lines seen */
};
struct list_result
{
int32_t fe_type; /* 'd'(dir) or 'l'(link) or 'f'(file) */
const char * fe_fname; /* pointer to filename */
uint32_t fe_fnlen; /* length of filename */
const char * fe_lname; /* pointer to symlink name */
uint32_t fe_lnlen; /* length of symlink name */
char fe_size[40]; /* size of file in bytes (<= (2^128 - 1)) */
PRExplodedTime fe_time; /* last-modified time */
int32_t fe_cinfs; /* file system is definitely case insensitive */
/* (converting all-upcase names may be desirable) */
};
int ParseFTPList(const char *line,
struct list_state *state,
struct list_result *result );
#endif /* !ParseRTPList_h___ */

View file

@ -0,0 +1,39 @@
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
XPIDL_SOURCES += [
'nsICompressConvStats.idl'
]
XPIDL_MODULE = 'necko_http'
UNIFIED_SOURCES += [
'mozTXTToHTMLConv.cpp',
'nsDirIndex.cpp',
'nsDirIndexParser.cpp',
'nsHTTPCompressConv.cpp',
'nsIndexedToHTML.cpp',
'nsMultiMixedConv.cpp',
'nsTXTToHTMLConv.cpp',
'nsUnknownDecoder.cpp',
]
if 'ftp' in CONFIG['NECKO_PROTOCOLS']:
UNIFIED_SOURCES += [
'nsFTPDirListingConv.cpp',
'ParseFTPList.cpp',
]
if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'cocoa':
UNIFIED_SOURCES += [
'nsBinHexDecoder.cpp',
]
FINAL_LIBRARY = 'xul'
LOCAL_INCLUDES += [
'/netwerk/base',
]

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,294 @@
/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
Description: Currently only functions to enhance plain text with HTML tags. See mozITXTToHTMLConv. Stream conversion is defunct.
*/
#ifndef _mozTXTToHTMLConv_h__
#define _mozTXTToHTMLConv_h__
#include "mozITXTToHTMLConv.h"
#include "nsString.h"
#include "nsCOMPtr.h"
class nsIIOService;
class mozTXTToHTMLConv : public mozITXTToHTMLConv
{
virtual ~mozTXTToHTMLConv();
//////////////////////////////////////////////////////////
public:
//////////////////////////////////////////////////////////
mozTXTToHTMLConv();
NS_DECL_ISUPPORTS
NS_DECL_MOZITXTTOHTMLCONV
NS_DECL_NSIREQUESTOBSERVER
NS_DECL_NSISTREAMLISTENER
NS_DECL_NSISTREAMCONVERTER
/**
see mozITXTToHTMLConv::ScanTXT
*/
void ScanTXT(const char16_t * aInString, int32_t aInStringLength, uint32_t whattodo, nsString& aOutString);
/**
see mozITXTToHTMLConv::ScanHTML. We will modify aInString potentially...
*/
void ScanHTML(nsString& aInString, uint32_t whattodo, nsString &aOutString);
/**
see mozITXTToHTMLConv::CiteLevelTXT
*/
int32_t CiteLevelTXT(const char16_t * line,uint32_t& logLineStart);
//////////////////////////////////////////////////////////
protected:
//////////////////////////////////////////////////////////
nsCOMPtr<nsIIOService> mIOService; // for performance reasons, cache the netwerk service...
/**
Completes<ul>
<li>Case 1: mailto: "mozilla@bucksch.org" -> "mailto:mozilla@bucksch.org"
<li>Case 2: http: "www.mozilla.org" -> "http://www.mozilla.org"
<li>Case 3: ftp: "ftp.mozilla.org" -> "ftp://www.mozilla.org"
</ul>
It does no check, if the resulting URL is valid.
@param text (in): abbreviated URL
@param pos (in): position of "@" (case 1) or first "." (case 2 and 3)
@return Completed URL at success and empty string at failure
*/
void CompleteAbbreviatedURL(const char16_t * aInString, int32_t aInLength,
const uint32_t pos, nsString& aOutString);
//////////////////////////////////////////////////////////
private:
//////////////////////////////////////////////////////////
enum LIMTYPE
{
LT_IGNORE, // limitation not checked
LT_DELIMITER, // not alphanumeric and not rep[0]. End of text is also ok.
LT_ALPHA, // alpha char
LT_DIGIT
};
/**
@param text (in): the string to search through.<p>
If before = IGNORE,<br>
rep is compared starting at 1. char of text (text[0]),<br>
else starting at 2. char of text (text[1]).
Chars after "after"-delimiter are ignored.
@param rep (in): the string to look for
@param aRepLen (in): the number of bytes in the string to look for
@param before (in): limitation before rep
@param after (in): limitation after rep
@return true, if rep is found and limitation spec is met or rep is empty
*/
bool ItMatchesDelimited(const char16_t * aInString, int32_t aInLength,
const char16_t * rep, int32_t aRepLen, LIMTYPE before, LIMTYPE after);
/**
@param see ItMatchesDelimited
@return Number of ItMatchesDelimited in text
*/
uint32_t NumberOfMatches(const char16_t * aInString, int32_t aInStringLength,
const char16_t* rep, int32_t aRepLen, LIMTYPE before, LIMTYPE after);
/**
Currently only changes "<", ">" and "&". All others stay as they are.<p>
"Char" in function name to avoid side effects with nsString(ch)
constructors.
@param ch (in)
@param aStringToAppendto (out) - the string to append the escaped
string to.
@param inAttribute (in) - will escape quotes, too (which is
only needed for attribute values)
*/
void EscapeChar(const char16_t ch, nsString& aStringToAppendto,
bool inAttribute);
/**
See EscapeChar. Escapes the string in place.
*/
void EscapeStr(nsString& aInString, bool inAttribute);
/**
Currently only reverts "<", ">" and "&". All others stay as they are.<p>
@param aInString (in) HTML string
@param aStartPos (in) start index into the buffer
@param aLength (in) length of the buffer
@param aOutString (out) unescaped buffer
*/
void UnescapeStr(const char16_t * aInString, int32_t aStartPos,
int32_t aLength, nsString& aOutString);
/**
<em>Note</em>: I use different strategies to pass context between the
functions (full text and pos vs. cutted text and col0, glphyTextLen vs.
replaceBefore/-After). It makes some sense, but is hard to understand
(maintain) :-(.
*/
/**
<p><em>Note:</em> replaceBefore + replaceAfter + 1 (for char at pos) chars
in text should be replaced by outputHTML.</p>
<p><em>Note:</em> This function should be able to process a URL on multiple
lines, but currently, ScanForURLs is called for every line, so it can't.</p>
@param text (in): includes possibly a URL
@param pos (in): position in text, where either ":", "." or "@" are found
@param whathasbeendone (in): What the calling ScanTXT did/has to do with the
(not-linkified) text, i.e. usually the "whattodo" parameter.
(Needed to calculate replaceBefore.) NOT what will be done with
the content of the link.
@param outputHTML (out): URL with HTML-a tag
@param replaceBefore (out): Number of chars of URL before pos
@param replaceAfter (out): Number of chars of URL after pos
@return URL found
*/
bool FindURL(const char16_t * aInString, int32_t aInLength, const uint32_t pos,
const uint32_t whathasbeendone,
nsString& outputHTML, int32_t& replaceBefore, int32_t& replaceAfter);
enum modetype {
unknown,
RFC1738, /* Check, if RFC1738, APPENDIX compliant,
like "<URL:http://www.mozilla.org>". */
RFC2396E, /* RFC2396, APPENDIX E allows anglebrackets (like
"<http://www.mozilla.org>") (without "URL:") or
quotation marks(like ""http://www.mozilla.org"").
Also allow email addresses without scheme,
e.g. "<mozilla@bucksch.org>" */
freetext, /* assume heading scheme
with "[a-zA-Z][a-zA-Z0-9+\-\.]*:" like "news:"
(see RFC2396, Section 3.1).
Certain characters (see code) or any whitespace
(including linebreaks) end the URL.
Other certain (punctation) characters (see code)
at the end are stripped off. */
abbreviated /* Similar to freetext, but without scheme, e.g.
"www.mozilla.org", "ftp.mozilla.org" and
"mozilla@bucksch.org". */
/* RFC1738 and RFC2396E type URLs may use multiple lines,
whitespace is stripped. Special characters like ")" stay intact.*/
};
/**
* @param text (in), pos (in): see FindURL
* @param check (in): Start must be conform with this mode
* @param start (out): Position in text, where URL (including brackets or
* similar) starts
* @return |check|-conform start has been found
*/
bool FindURLStart(const char16_t * aInString, int32_t aInLength, const uint32_t pos,
const modetype check, uint32_t& start);
/**
* @param text (in), pos (in): see FindURL
* @param check (in): End must be conform with this mode
* @param start (in): see FindURLStart
* @param end (out): Similar to |start| param of FindURLStart
* @return |check|-conform end has been found
*/
bool FindURLEnd(const char16_t * aInString, int32_t aInStringLength, const uint32_t pos,
const modetype check, const uint32_t start, uint32_t& end);
/**
* @param text (in), pos (in), whathasbeendone (in): see FindURL
* @param check (in): Current mode
* @param start (in), end (in): see FindURLEnd
* @param txtURL (out): Guessed (raw) URL.
* Without whitespace, but not completed.
* @param desc (out): Link as shown to the user, but already escaped.
* Should be placed between the <a> and </a> tags.
* @param replaceBefore(out), replaceAfter (out): see FindURL
*/
void CalculateURLBoundaries(const char16_t * aInString, int32_t aInStringLength,
const uint32_t pos, const uint32_t whathasbeendone,
const modetype check, const uint32_t start, const uint32_t end,
nsString& txtURL, nsString& desc,
int32_t& replaceBefore, int32_t& replaceAfter);
/**
* @param txtURL (in), desc (in): see CalculateURLBoundaries
* @param outputHTML (out): see FindURL
* @return A valid URL could be found (and creation of HTML successful)
*/
bool CheckURLAndCreateHTML(
const nsString& txtURL, const nsString& desc, const modetype mode,
nsString& outputHTML);
/**
@param text (in): line of text possibly with tagTXT.<p>
if col0 is true,
starting with tagTXT<br>
else
starting one char before tagTXT
@param col0 (in): tagTXT is on the beginning of the line (or paragraph).
open must be 0 then.
@param tagTXT (in): Tag in plaintext to search for, e.g. "*"
@param aTagTxtLen (in): length of tagTXT.
@param tagHTML (in): HTML-Tag to replace tagTXT with,
without "<" and ">", e.g. "strong"
@param attributeHTML (in): HTML-attribute to add to opening tagHTML,
e.g. "class=txt_star"
@param aOutString: string to APPEND the converted html into
@param open (in/out): Number of currently open tags of type tagHTML
@return Conversion succeeded
*/
bool StructPhraseHit(const char16_t * aInString, int32_t aInStringLength, bool col0,
const char16_t* tagTXT,
int32_t aTagTxtLen,
const char* tagHTML, const char* attributeHTML,
nsString& aOutputString, uint32_t& openTags);
/**
@param text (in), col0 (in): see GlyphHit
@param tagTXT (in): Smily, see also StructPhraseHit
@param imageName (in): the basename of the file that contains the image for this smilie
@param outputHTML (out): new string containing the html for the smily
@param glyphTextLen (out): see GlyphHit
*/
bool
SmilyHit(const char16_t * aInString, int32_t aLength, bool col0,
const char* tagTXT, const char* imageName,
nsString& outputHTML, int32_t& glyphTextLen);
/**
Checks, if we can replace some chars at the start of line with prettier HTML
code.<p>
If success is reported, replace the first glyphTextLen chars with outputHTML
@param text (in): line of text possibly with Glyph.<p>
If col0 is true,
starting with Glyph <br><!-- (br not part of text) -->
else
starting one char before Glyph
@param col0 (in): text starts at the beginning of the line (or paragraph)
@param aOutString (out): APPENDS html for the glyph to this string
@param glyphTextLen (out): Length of original text to replace
@return see StructPhraseHit
*/
bool GlyphHit(const char16_t * aInString, int32_t aInLength, bool col0,
nsString& aOutString, int32_t& glyphTextLen);
/**
Check if a given url should be linkified.
@param aURL (in): url to be checked on.
*/
bool ShouldLinkify(const nsCString& aURL);
};
// It's said, that Win32 and Mac don't like static const members
const int32_t mozTXTToHTMLConv_lastMode = 4;
// Needed (only) by mozTXTToHTMLConv::FindURL
const int32_t mozTXTToHTMLConv_numberOfModes = 4; // dito; unknown not counted
#endif

View file

@ -0,0 +1,520 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsIOService.h"
#include "nsBinHexDecoder.h"
#include "nsIServiceManager.h"
#include "nsIStreamConverterService.h"
#include "nsCRT.h"
#include "nsIPipe.h"
#include "nsMimeTypes.h"
#include "netCore.h"
#include "nsXPIDLString.h"
#include "prnetdb.h"
#include "nsIURI.h"
#include "nsIURL.h"
#include "nsIMIMEService.h"
#include "nsMimeTypes.h"
#include <algorithm>
namespace mozilla {
namespace net {
nsBinHexDecoder::nsBinHexDecoder() :
mState(0), mCRC(0), mFileCRC(0), mOctetin(26),
mDonePos(3), mInCRC(0), mCount(0), mMarker(0), mPosInbuff(0),
mPosOutputBuff(0)
{
mDataBuffer = nullptr;
mOutgoingBuffer = nullptr;
mPosInDataBuffer = 0;
mRlebuf = 0;
mOctetBuf.val = 0;
mHeader.type = 0;
mHeader.creator = 0;
mHeader.flags = 0;
mHeader.dlen = 0;
mHeader.rlen = 0;
}
nsBinHexDecoder::~nsBinHexDecoder()
{
if (mDataBuffer)
free(mDataBuffer);
if (mOutgoingBuffer)
free(mOutgoingBuffer);
}
NS_IMPL_ADDREF(nsBinHexDecoder)
NS_IMPL_RELEASE(nsBinHexDecoder)
NS_INTERFACE_MAP_BEGIN(nsBinHexDecoder)
NS_INTERFACE_MAP_ENTRY(nsIStreamConverter)
NS_INTERFACE_MAP_ENTRY(nsIStreamListener)
NS_INTERFACE_MAP_ENTRY(nsIRequestObserver)
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END
// The binhex 4.0 decoder table....
static const signed char binhex_decode[256] =
{
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, -1, -1,
13, 14, 15, 16, 17, 18, 19, -1, 20, 21, -1, -1, -1, -1, -1, -1,
22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, -1,
37, 38, 39, 40, 41, 42, 43, -1, 44, 45, 46, 47, -1, -1, -1, -1,
48, 49, 50, 51, 52, 53, 54, -1, 55, 56, 57, 58, 59, 60, -1, -1,
61, 62, 63, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
};
#define BHEXVAL(c) (binhex_decode[(unsigned char) c])
//////////////////////////////////////////////////////
// nsIStreamConverter methods...
//////////////////////////////////////////////////////
NS_IMETHODIMP
nsBinHexDecoder::Convert(nsIInputStream *aFromStream,
const char *aFromType,
const char *aToType,
nsISupports *aCtxt,
nsIInputStream **aResultStream)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsBinHexDecoder::AsyncConvertData(const char *aFromType,
const char *aToType,
nsIStreamListener *aListener,
nsISupports *aCtxt)
{
NS_ASSERTION(aListener && aFromType && aToType,
"null pointer passed into bin hex converter");
// hook up our final listener. this guy gets the various On*() calls we want to throw
// at him.
//
mNextListener = aListener;
return (aListener) ? NS_OK : NS_ERROR_FAILURE;
}
//////////////////////////////////////////////////////
// nsIStreamListener methods...
//////////////////////////////////////////////////////
NS_IMETHODIMP
nsBinHexDecoder::OnDataAvailable(nsIRequest* request,
nsISupports *aCtxt,
nsIInputStream *aStream,
uint64_t aSourceOffset,
uint32_t aCount)
{
nsresult rv = NS_OK;
if (mOutputStream && mDataBuffer && aCount > 0)
{
uint32_t numBytesRead = 0;
while (aCount > 0) // while we still have bytes to copy...
{
aStream->Read(mDataBuffer, std::min(aCount, nsIOService::gDefaultSegmentSize - 1), &numBytesRead);
if (aCount >= numBytesRead)
aCount -= numBytesRead; // subtract off the number of bytes we just read
else
aCount = 0;
// Process this new chunk of bin hex data...
ProcessNextChunk(request, aCtxt, numBytesRead);
}
}
return rv;
}
nsresult nsBinHexDecoder::ProcessNextState(nsIRequest * aRequest, nsISupports * aContext)
{
nsresult status = NS_OK;
uint16_t tmpcrc, cval;
unsigned char ctmp, c = mRlebuf;
/* do CRC */
ctmp = mInCRC ? c : 0;
cval = mCRC & 0xf000;
tmpcrc = ((uint16_t) (mCRC << 4) | (ctmp >> 4)) ^ (cval | (cval >> 7) | (cval >> 12));
cval = tmpcrc & 0xf000;
mCRC = ((uint16_t) (tmpcrc << 4) | (ctmp & 0x0f)) ^ (cval | (cval >> 7) | (cval >> 12));
/* handle state */
switch (mState)
{
case BINHEX_STATE_START:
mState = BINHEX_STATE_FNAME;
mCount = 0;
// c & 63 returns the length of mName. So if we need the length, that's how
// you can figure it out....
mName.SetLength(c & 63);
if (mName.Length() != (c & 63)) {
/* XXX ProcessNextState/ProcessNextChunk aren't rv checked */
mState = BINHEX_STATE_DONE;
}
break;
case BINHEX_STATE_FNAME:
if (mCount < mName.Length()) {
mName.BeginWriting()[mCount] = c;
}
if (++mCount > mName.Length())
{
// okay we've figured out the file name....set the content type on the channel
// based on the file name AND issue our delayed on start request....
DetectContentType(aRequest, mName);
// now propagate the on start request
mNextListener->OnStartRequest(aRequest, aContext);
mState = BINHEX_STATE_HEADER;
mCount = 0;
}
break;
case BINHEX_STATE_HEADER:
((char *) &mHeader)[mCount] = c;
if (++mCount == 18)
{
if (sizeof(binhex_header) != 18) /* fix an alignment problem in some OSes */
{
char *p = (char *)&mHeader;
p += 19;
for (c = 0; c < 8; c++)
{
*p = *(p-2);
--p;
}
}
mState = BINHEX_STATE_HCRC;
mInCRC = 1;
mCount = 0;
}
break;
case BINHEX_STATE_DFORK:
case BINHEX_STATE_RFORK:
mOutgoingBuffer[mPosOutputBuff++] = c;
if (--mCount == 0)
{
/* only output data fork in the non-mac system. */
if (mState == BINHEX_STATE_DFORK)
{
uint32_t numBytesWritten = 0;
mOutputStream->Write(mOutgoingBuffer, mPosOutputBuff, &numBytesWritten);
if (int32_t(numBytesWritten) != mPosOutputBuff)
status = NS_ERROR_FAILURE;
// now propagate the data we just wrote
mNextListener->OnDataAvailable(aRequest, aContext, mInputStream, 0, numBytesWritten);
}
else
status = NS_OK; /* do nothing for resource fork. */
mPosOutputBuff = 0;
if (status != NS_OK)
mState = BINHEX_STATE_DONE;
else
++mState;
mInCRC = 1;
}
else if (mPosOutputBuff >= (int32_t) nsIOService::gDefaultSegmentSize)
{
if (mState == BINHEX_STATE_DFORK)
{
uint32_t numBytesWritten = 0;
mOutputStream->Write(mOutgoingBuffer, mPosOutputBuff, &numBytesWritten);
if (int32_t(numBytesWritten) != mPosOutputBuff)
status = NS_ERROR_FAILURE;
mNextListener->OnDataAvailable(aRequest, aContext, mInputStream, 0, numBytesWritten);
mPosOutputBuff = 0;
}
}
break;
case BINHEX_STATE_HCRC:
case BINHEX_STATE_DCRC:
case BINHEX_STATE_RCRC:
if (!mCount++)
mFileCRC = (unsigned short) c << 8;
else
{
if ((mFileCRC | c) != mCRC)
{
mState = BINHEX_STATE_DONE;
break;
}
/* passed the CRC check!!!*/
mCRC = 0;
if (++mState == BINHEX_STATE_FINISH)
{
// when we reach the finished state...fire an on stop request on the event listener...
mNextListener->OnStopRequest(aRequest, aContext, NS_OK);
mNextListener = nullptr;
/* now We are done with everything. */
++mState;
break;
}
if (mState == BINHEX_STATE_DFORK)
mCount = PR_ntohl(mHeader.dlen);
else
{
// we aren't processing the resurce Fork. uncomment this line if we make this converter
// smart enough to do this in the future.
// mCount = PR_ntohl(mHeader.rlen); /* it should in host byte order */
mCount = 0;
}
if (mCount) {
mInCRC = 0;
} else {
/* nothing inside, so skip to the next state. */
++mState;
}
}
break;
}
return NS_OK;
}
nsresult nsBinHexDecoder::ProcessNextChunk(nsIRequest * aRequest, nsISupports * aContext, uint32_t numBytesInBuffer)
{
bool foundStart;
int16_t octetpos, c = 0;
uint32_t val;
mPosInDataBuffer = 0; // use member variable.
NS_ENSURE_TRUE(numBytesInBuffer > 0, NS_ERROR_FAILURE);
// if it is the first time, seek to the right start place.
if (mState == BINHEX_STATE_START)
{
foundStart = false;
// go through the line, until we get a ':'
while (mPosInDataBuffer < numBytesInBuffer)
{
c = mDataBuffer[mPosInDataBuffer++];
while (c == nsCRT::CR || c == nsCRT::LF)
{
if (mPosInDataBuffer >= numBytesInBuffer)
break;
c = mDataBuffer[mPosInDataBuffer++];
if (c == ':')
{
foundStart = true;
break;
}
}
if (foundStart) break; /* we got the start point. */
}
if (mPosInDataBuffer >= numBytesInBuffer)
return NS_OK; /* we meet buff end before we get the start point, wait till next fills. */
if (c != ':')
return NS_ERROR_FAILURE; /* can't find the start character. */
}
while (mState != BINHEX_STATE_DONE)
{
/* fill in octetbuf */
do
{
if (mPosInDataBuffer >= numBytesInBuffer)
return NS_OK; /* end of buff, go on for the nxet calls. */
c = GetNextChar(numBytesInBuffer);
if (c == 0) return NS_OK;
if ((val = BHEXVAL(c)) == uint32_t(-1))
{
/* we incount an invalid character. */
if (c)
{
/* rolling back. */
--mDonePos;
if (mOctetin >= 14)
--mDonePos;
if (mOctetin >= 20)
--mDonePos;
}
break;
}
mOctetBuf.val |= val << mOctetin;
}
while ((mOctetin -= 6) > 2);
/* handle decoded characters -- run length encoding (rle) detection */
// We put decoded chars into mOctetBuf.val in order from high to low (via
// bitshifting, above). But we want to byte-address them, so we want the
// first byte to correspond to the high byte. In other words, we want
// these bytes to be in network order.
mOctetBuf.val = PR_htonl(mOctetBuf.val);
for (octetpos = 0; octetpos < mDonePos; ++octetpos)
{
c = mOctetBuf.c[octetpos];
if (c == 0x90 && !mMarker++)
continue;
if (mMarker)
{
if (c == 0)
{
mRlebuf = 0x90;
ProcessNextState(aRequest, aContext);
}
else
{
/* we are in the run length mode */
while (--c > 0)
ProcessNextState(aRequest, aContext);
}
mMarker = 0;
}
else
{
mRlebuf = (unsigned char) c;
ProcessNextState(aRequest, aContext);
}
if (mState >= BINHEX_STATE_DONE)
break;
}
/* prepare for next 3 characters. */
if (mDonePos < 3 && mState < BINHEX_STATE_DONE)
mState = BINHEX_STATE_DONE;
mOctetin = 26;
mOctetBuf.val = 0;
}
return NS_OK;
}
int16_t nsBinHexDecoder::GetNextChar(uint32_t numBytesInBuffer)
{
char c = 0;
while (mPosInDataBuffer < numBytesInBuffer)
{
c = mDataBuffer[mPosInDataBuffer++];
if (c != nsCRT::LF && c != nsCRT::CR)
break;
}
return (c == nsCRT::LF || c == nsCRT::CR) ? 0 : (int) c;
}
//////////////////////////////////////////////////////
// nsIRequestObserver methods...
//////////////////////////////////////////////////////
NS_IMETHODIMP
nsBinHexDecoder::OnStartRequest(nsIRequest* request, nsISupports *aCtxt)
{
nsresult rv = NS_OK;
NS_ENSURE_TRUE(mNextListener, NS_ERROR_FAILURE);
mDataBuffer = (char *) malloc((sizeof(char) * nsIOService::gDefaultSegmentSize));
mOutgoingBuffer = (char *) malloc((sizeof(char) * nsIOService::gDefaultSegmentSize));
if (!mDataBuffer || !mOutgoingBuffer) return NS_ERROR_FAILURE; // out of memory;
// now we want to create a pipe which we'll use to write our converted data...
rv = NS_NewPipe(getter_AddRefs(mInputStream), getter_AddRefs(mOutputStream),
nsIOService::gDefaultSegmentSize,
nsIOService::gDefaultSegmentSize,
true, true);
// don't propagate the on start request to mNextListener until we have determined the content type.
return rv;
}
// Given the fileName we discovered inside the bin hex decoding, figure out the
// content type and set it on the channel associated with the request. If the
// filename tells us nothing useful, just report an unknown type and let the
// unknown decoder handle things.
nsresult nsBinHexDecoder::DetectContentType(nsIRequest* aRequest,
const nsAFlatCString &aFilename)
{
if (aFilename.IsEmpty()) {
// Nothing to do here.
return NS_OK;
}
nsresult rv;
nsCOMPtr<nsIChannel> channel(do_QueryInterface(aRequest, &rv));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIMIMEService> mimeService(do_GetService("@mozilla.org/mime;1", &rv));
NS_ENSURE_SUCCESS(rv, rv);
nsAutoCString contentType;
// extract the extension from aFilename and look it up.
const char * fileExt = strrchr(aFilename.get(), '.');
if (!fileExt) {
return NS_OK;
}
mimeService->GetTypeFromExtension(nsDependentCString(fileExt), contentType);
// Only set the type if it's not empty and, to prevent recursive loops, not the binhex type
if (!contentType.IsEmpty() && !contentType.Equals(APPLICATION_BINHEX)) {
channel->SetContentType(contentType);
} else {
channel->SetContentType(NS_LITERAL_CSTRING(UNKNOWN_CONTENT_TYPE));
}
return NS_OK;
}
NS_IMETHODIMP
nsBinHexDecoder::OnStopRequest(nsIRequest* request, nsISupports *aCtxt,
nsresult aStatus)
{
nsresult rv = NS_OK;
if (!mNextListener) return NS_ERROR_FAILURE;
// don't do anything here...we'll fire our own on stop request when we are done
// processing the data....
return rv;
}
} // namespace net
} // namespace mozilla

View file

@ -0,0 +1,126 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// A decoder for Mac Bin Hex 4.0.
// This decoder is currently only intended to be used on NON-Mac platforms. It isn't hooked up to
// code which would actually save the file to disk. As a result, we can't leverage the resource fork.
// This makes this decoder most unhelpful for the Mac. Our assumption is that if you save a bin hex file
// on the mac and try to open it, stuffit or some other tool is already going to be on the Mac which knows how
// to handle bin hex. On windows and unix, that's not the case. We need client code to strip out the data fork.
// So this decoder currently just strips out the data fork.
// Note: it's possible that we can eventually turn this decoder into both a decoder and into a file stream (much
// like the apple double decoder) so on the Mac, if we are saving to disk, we can invoke the decoder as a file stream
// and it will process the resource fork and do the right magic.
#ifndef nsBinHexDecoder_h__
#define nsBinHexDecoder_h__
#include "nsIStreamConverter.h"
#include "nsIChannel.h"
#include "nsIOutputStream.h"
#include "nsIInputStream.h"
#include "nsCOMPtr.h"
#include "nsString.h"
#define NS_BINHEXDECODER_CID \
{ /* 301DEA42-6850-4cda-8945-81F7DBC2186B */ \
0x301dea42, 0x6850, 0x4cda, \
{ 0x89, 0x45, 0x81, 0xf7, 0xdb, 0xc2, 0x18, 0x6b } \
}
namespace mozilla {
namespace net {
typedef struct _binhex_header
{
uint32_t type, creator;
uint16_t flags;
int32_t dlen, rlen;
} binhex_header;
typedef union
{
unsigned char c[4];
uint32_t val;
} longbuf;
#define BINHEX_STATE_START 0
#define BINHEX_STATE_FNAME 1
#define BINHEX_STATE_HEADER 2
#define BINHEX_STATE_HCRC 3
#define BINHEX_STATE_DFORK 4
#define BINHEX_STATE_DCRC 5
#define BINHEX_STATE_RFORK 6
#define BINHEX_STATE_RCRC 7
#define BINHEX_STATE_FINISH 8
#define BINHEX_STATE_DONE 9
/* #define BINHEX_STATE_ERROR 10 */
class nsBinHexDecoder : public nsIStreamConverter
{
public:
// nsISupports methods
NS_DECL_ISUPPORTS
// nsIStreamConverter methods
NS_DECL_NSISTREAMCONVERTER
// nsIStreamListener methods
NS_DECL_NSISTREAMLISTENER
// nsIRequestObserver methods
NS_DECL_NSIREQUESTOBSERVER
nsBinHexDecoder();
protected:
virtual ~nsBinHexDecoder();
int16_t GetNextChar(uint32_t numBytesInBuffer);
nsresult ProcessNextChunk(nsIRequest * aRequest, nsISupports * aContext, uint32_t numBytesInBuffer);
nsresult ProcessNextState(nsIRequest * aRequest, nsISupports * aContext);
nsresult DetectContentType(nsIRequest * aRequest, const nsAFlatCString &aFilename);
protected:
nsCOMPtr<nsIStreamListener> mNextListener;
// the input and output streams form a pipe...they need to be passed around together..
nsCOMPtr<nsIOutputStream> mOutputStream; // output stream
nsCOMPtr<nsIInputStream> mInputStream;
int16_t mState; /* current state */
uint16_t mCRC; /* cumulative CRC */
uint16_t mFileCRC; /* CRC value from file */
longbuf mOctetBuf; /* buffer for decoded 6-bit values */
int16_t mOctetin; /* current input position in octetbuf */
int16_t mDonePos; /* ending position in octetbuf */
int16_t mInCRC; /* flag set when reading a CRC */
// Bin Hex Header Information
binhex_header mHeader;
nsCString mName; /* fsspec for the output file */
// unfortunately we are going to need 2 8K buffers here. One for the data we are currently digesting. Another
// for the outgoing decoded data. I tried getting them to share a buffer but things didn't work out so nicely.
char * mDataBuffer; // temporary holding pen for the incoming data.
char * mOutgoingBuffer; // temporary holding pen for the incoming data.
uint32_t mPosInDataBuffer;
unsigned char mRlebuf; /* buffer for last run length encoding value */
uint32_t mCount; /* generic counter */
int16_t mMarker; /* flag indicating maker */
int32_t mPosInbuff; /* the index of the inbuff. */
int32_t mPosOutputBuff; /* the position of the out buff. */
};
} // namespace net
} // namespace mozilla
#endif /* nsBinHexDecoder_h__ */

View file

@ -0,0 +1,122 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsDirIndex.h"
NS_IMPL_ISUPPORTS(nsDirIndex,
nsIDirIndex)
nsDirIndex::nsDirIndex() : mType(TYPE_UNKNOWN),
mSize(UINT64_MAX),
mLastModified(-1LL)
{
}
nsDirIndex::~nsDirIndex() {}
NS_IMETHODIMP
nsDirIndex::GetType(uint32_t* aType)
{
NS_ENSURE_ARG_POINTER(aType);
*aType = mType;
return NS_OK;
}
NS_IMETHODIMP
nsDirIndex::SetType(uint32_t aType)
{
mType = aType;
return NS_OK;
}
NS_IMETHODIMP
nsDirIndex::GetContentType(char* *aContentType)
{
NS_ENSURE_ARG_POINTER(aContentType);
*aContentType = ToNewCString(mContentType);
if (!*aContentType)
return NS_ERROR_OUT_OF_MEMORY;
return NS_OK;
}
NS_IMETHODIMP
nsDirIndex::SetContentType(const char* aContentType)
{
mContentType = aContentType;
return NS_OK;
}
NS_IMETHODIMP
nsDirIndex::GetLocation(char* *aLocation)
{
NS_ENSURE_ARG_POINTER(aLocation);
*aLocation = ToNewCString(mLocation);
if (!*aLocation)
return NS_ERROR_OUT_OF_MEMORY;
return NS_OK;
}
NS_IMETHODIMP
nsDirIndex::SetLocation(const char* aLocation)
{
mLocation = aLocation;
return NS_OK;
}
NS_IMETHODIMP
nsDirIndex::GetDescription(char16_t* *aDescription)
{
NS_ENSURE_ARG_POINTER(aDescription);
*aDescription = ToNewUnicode(mDescription);
if (!*aDescription)
return NS_ERROR_OUT_OF_MEMORY;
return NS_OK;
}
NS_IMETHODIMP
nsDirIndex::SetDescription(const char16_t* aDescription)
{
mDescription.Assign(aDescription);
return NS_OK;
}
NS_IMETHODIMP
nsDirIndex::GetSize(int64_t* aSize)
{
NS_ENSURE_ARG_POINTER(aSize);
*aSize = mSize;
return NS_OK;
}
NS_IMETHODIMP
nsDirIndex::SetSize(int64_t aSize)
{
mSize = aSize;
return NS_OK;
}
NS_IMETHODIMP
nsDirIndex::GetLastModified(PRTime* aLastModified)
{
NS_ENSURE_ARG_POINTER(aLastModified);
*aLastModified = mLastModified;
return NS_OK;
}
NS_IMETHODIMP
nsDirIndex::SetLastModified(PRTime aLastModified)
{
mLastModified = aLastModified;
return NS_OK;
}

View file

@ -0,0 +1,30 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsIDirIndex.h"
#include "nsString.h"
#include "mozilla/Attributes.h"
/* CID: {f6913e2e-1dd1-11b2-84be-f455dee342af} */
class nsDirIndex final : public nsIDirIndex {
private:
~nsDirIndex();
public:
nsDirIndex();
NS_DECL_ISUPPORTS
NS_DECL_NSIDIRINDEX
protected:
uint32_t mType;
nsXPIDLCString mContentType;
nsXPIDLCString mLocation;
nsString mDescription;
int64_t mSize;
PRTime mLastModified;
};

View file

@ -0,0 +1,427 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* This parsing code originally lived in xpfe/components/directory/ - bbaetz */
#include "mozilla/ArrayUtils.h"
#include "prprf.h"
#include "nsDirIndexParser.h"
#include "nsEscape.h"
#include "nsIInputStream.h"
#include "nsCRT.h"
#include "mozilla/dom/FallbackEncoding.h"
#include "nsITextToSubURI.h"
#include "nsIDirIndex.h"
#include "nsServiceManagerUtils.h"
using namespace mozilla;
NS_IMPL_ISUPPORTS(nsDirIndexParser,
nsIRequestObserver,
nsIStreamListener,
nsIDirIndexParser)
nsDirIndexParser::nsDirIndexParser() {
}
nsresult
nsDirIndexParser::Init() {
mLineStart = 0;
mHasDescription = false;
mFormat[0] = -1;
mozilla::dom::FallbackEncoding::FromLocale(mEncoding);
nsresult rv;
// XXX not threadsafe
if (gRefCntParser++ == 0)
rv = CallGetService(NS_ITEXTTOSUBURI_CONTRACTID, &gTextToSubURI);
else
rv = NS_OK;
return rv;
}
nsDirIndexParser::~nsDirIndexParser() {
// XXX not threadsafe
if (--gRefCntParser == 0) {
NS_IF_RELEASE(gTextToSubURI);
}
}
NS_IMETHODIMP
nsDirIndexParser::SetListener(nsIDirIndexListener* aListener) {
mListener = aListener;
return NS_OK;
}
NS_IMETHODIMP
nsDirIndexParser::GetListener(nsIDirIndexListener** aListener) {
NS_IF_ADDREF(*aListener = mListener.get());
return NS_OK;
}
NS_IMETHODIMP
nsDirIndexParser::GetComment(char** aComment) {
*aComment = ToNewCString(mComment);
if (!*aComment)
return NS_ERROR_OUT_OF_MEMORY;
return NS_OK;
}
NS_IMETHODIMP
nsDirIndexParser::SetEncoding(const char* aEncoding) {
mEncoding.Assign(aEncoding);
return NS_OK;
}
NS_IMETHODIMP
nsDirIndexParser::GetEncoding(char** aEncoding) {
*aEncoding = ToNewCString(mEncoding);
if (!*aEncoding)
return NS_ERROR_OUT_OF_MEMORY;
return NS_OK;
}
NS_IMETHODIMP
nsDirIndexParser::OnStartRequest(nsIRequest* aRequest, nsISupports* aCtxt) {
return NS_OK;
}
NS_IMETHODIMP
nsDirIndexParser::OnStopRequest(nsIRequest *aRequest, nsISupports *aCtxt,
nsresult aStatusCode) {
// Finish up
if (mBuf.Length() > (uint32_t) mLineStart) {
ProcessData(aRequest, aCtxt);
}
return NS_OK;
}
nsDirIndexParser::Field
nsDirIndexParser::gFieldTable[] = {
{ "Filename", FIELD_FILENAME },
{ "Description", FIELD_DESCRIPTION },
{ "Content-Length", FIELD_CONTENTLENGTH },
{ "Last-Modified", FIELD_LASTMODIFIED },
{ "Content-Type", FIELD_CONTENTTYPE },
{ "File-Type", FIELD_FILETYPE },
{ nullptr, FIELD_UNKNOWN }
};
nsrefcnt nsDirIndexParser::gRefCntParser = 0;
nsITextToSubURI *nsDirIndexParser::gTextToSubURI;
nsresult
nsDirIndexParser::ParseFormat(const char* aFormatStr)
{
// Parse a "200" format line, and remember the fields and their
// ordering in mFormat. Multiple 200 lines stomp on each other.
unsigned int formatNum = 0;
mFormat[0] = -1;
do {
while (*aFormatStr && nsCRT::IsAsciiSpace(char16_t(*aFormatStr)))
++aFormatStr;
if (! *aFormatStr)
break;
nsAutoCString name;
int32_t len = 0;
while (aFormatStr[len] && !nsCRT::IsAsciiSpace(char16_t(aFormatStr[len])))
++len;
name.SetCapacity(len + 1);
name.Append(aFormatStr, len);
aFormatStr += len;
// Okay, we're gonna monkey with the nsStr. Bold!
name.SetLength(nsUnescapeCount(name.BeginWriting()));
// All tokens are case-insensitive - http://www.mozilla.org/projects/netlib/dirindexformat.html
if (name.LowerCaseEqualsLiteral("description"))
mHasDescription = true;
for (Field* i = gFieldTable; i->mName; ++i) {
if (name.EqualsIgnoreCase(i->mName)) {
mFormat[formatNum] = i->mType;
mFormat[++formatNum] = -1;
break;
}
}
} while (*aFormatStr && (formatNum < (ArrayLength(mFormat)-1)));
return NS_OK;
}
nsresult
nsDirIndexParser::ParseData(nsIDirIndex *aIdx, char* aDataStr, int32_t aLineLen)
{
// Parse a "201" data line, using the field ordering specified in
// mFormat.
if(mFormat[0] == -1) {
// Ignore if we haven't seen a format yet.
return NS_OK;
}
nsresult rv = NS_OK;
nsAutoCString filename;
int32_t lineLen = aLineLen;
for (int32_t i = 0; mFormat[i] != -1; ++i) {
// If we've exhausted the data before we run out of fields, just bail.
if (!*aDataStr || (lineLen < 1)) {
return NS_OK;
}
while ((lineLen > 0) && nsCRT::IsAsciiSpace(*aDataStr)) {
++aDataStr;
--lineLen;
}
if (lineLen < 1) {
// invalid format, bail
return NS_OK;
}
char *value = aDataStr;
if (*aDataStr == '"' || *aDataStr == '\'') {
// it's a quoted string. snarf everything up to the next quote character
const char quotechar = *(aDataStr++);
lineLen--;
++value;
while ((lineLen > 0) && *aDataStr != quotechar) {
++aDataStr;
--lineLen;
}
if (lineLen > 0) {
*aDataStr++ = '\0';
--lineLen;
}
if (!lineLen) {
// invalid format, bail
return NS_OK;
}
} else {
// it's unquoted. snarf until we see whitespace.
value = aDataStr;
while ((lineLen > 0) && (!nsCRT::IsAsciiSpace(*aDataStr))) {
++aDataStr;
--lineLen;
}
if (lineLen > 0) {
*aDataStr++ = '\0';
--lineLen;
}
// even if we ran out of line length here, there's still a trailing zero
// byte afterwards
}
fieldType t = fieldType(mFormat[i]);
switch (t) {
case FIELD_FILENAME: {
// don't unescape at this point, so that UnEscapeAndConvert() can
filename = value;
bool success = false;
nsAutoString entryuri;
if (gTextToSubURI) {
char16_t *result = nullptr;
if (NS_SUCCEEDED(rv = gTextToSubURI->UnEscapeAndConvert(mEncoding.get(), filename.get(),
&result)) && (result)) {
if (*result) {
aIdx->SetLocation(filename.get());
if (!mHasDescription)
aIdx->SetDescription(result);
success = true;
}
free(result);
} else {
NS_WARNING("UnEscapeAndConvert error");
}
}
if (!success) {
// if unsuccessfully at charset conversion, then
// just fallback to unescape'ing in-place
// XXX - this shouldn't be using UTF8, should it?
// when can we fail to get the service, anyway? - bbaetz
aIdx->SetLocation(filename.get());
if (!mHasDescription) {
aIdx->SetDescription(NS_ConvertUTF8toUTF16(value).get());
}
}
}
break;
case FIELD_DESCRIPTION:
nsUnescape(value);
aIdx->SetDescription(NS_ConvertUTF8toUTF16(value).get());
break;
case FIELD_CONTENTLENGTH:
{
int64_t len;
int32_t status = PR_sscanf(value, "%lld", &len);
if (status == 1)
aIdx->SetSize(len);
else
aIdx->SetSize(UINT64_MAX); // UINT64_MAX means unknown
}
break;
case FIELD_LASTMODIFIED:
{
PRTime tm;
nsUnescape(value);
if (PR_ParseTimeString(value, false, &tm) == PR_SUCCESS) {
aIdx->SetLastModified(tm);
}
}
break;
case FIELD_CONTENTTYPE:
aIdx->SetContentType(value);
break;
case FIELD_FILETYPE:
// unescape in-place
nsUnescape(value);
if (!nsCRT::strcasecmp(value, "directory")) {
aIdx->SetType(nsIDirIndex::TYPE_DIRECTORY);
} else if (!nsCRT::strcasecmp(value, "file")) {
aIdx->SetType(nsIDirIndex::TYPE_FILE);
} else if (!nsCRT::strcasecmp(value, "symbolic-link")) {
aIdx->SetType(nsIDirIndex::TYPE_SYMLINK);
} else {
aIdx->SetType(nsIDirIndex::TYPE_UNKNOWN);
}
break;
case FIELD_UNKNOWN:
// ignore
break;
}
}
return NS_OK;
}
NS_IMETHODIMP
nsDirIndexParser::OnDataAvailable(nsIRequest *aRequest, nsISupports *aCtxt,
nsIInputStream *aStream,
uint64_t aSourceOffset,
uint32_t aCount) {
if (aCount < 1)
return NS_OK;
int32_t len = mBuf.Length();
// Ensure that our mBuf has capacity to hold the data we're about to
// read.
if (!mBuf.SetLength(len + aCount, fallible))
return NS_ERROR_OUT_OF_MEMORY;
// Now read the data into our buffer.
nsresult rv;
uint32_t count;
rv = aStream->Read(mBuf.BeginWriting() + len, aCount, &count);
if (NS_FAILED(rv)) return rv;
// Set the string's length according to the amount of data we've read.
// Note: we know this to work on nsCString. This isn't guaranteed to
// work on other strings.
mBuf.SetLength(len + count);
return ProcessData(aRequest, aCtxt);
}
nsresult
nsDirIndexParser::ProcessData(nsIRequest *aRequest, nsISupports *aCtxt) {
if (!mListener)
return NS_ERROR_FAILURE;
int32_t numItems = 0;
while(true) {
++numItems;
int32_t eol = mBuf.FindCharInSet("\n\r", mLineStart);
if (eol < 0) break;
mBuf.SetCharAt(char16_t('\0'), eol);
const char *line = mBuf.get() + mLineStart;
int32_t lineLen = eol - mLineStart;
mLineStart = eol + 1;
if (lineLen >= 4) {
nsresult rv;
const char *buf = line;
if (buf[0] == '1') {
if (buf[1] == '0') {
if (buf[2] == '0' && buf[3] == ':') {
// 100. Human-readable comment line. Ignore
} else if (buf[2] == '1' && buf[3] == ':') {
// 101. Human-readable information line.
mComment.Append(buf + 4);
char *value = ((char *)buf) + 4;
nsUnescape(value);
mListener->OnInformationAvailable(aRequest, aCtxt, NS_ConvertUTF8toUTF16(value));
} else if (buf[2] == '2' && buf[3] == ':') {
// 102. Human-readable information line, HTML.
mComment.Append(buf + 4);
}
}
} else if (buf[0] == '2') {
if (buf[1] == '0') {
if (buf[2] == '0' && buf[3] == ':') {
// 200. Define field names
rv = ParseFormat(buf + 4);
if (NS_FAILED(rv)) {
return rv;
}
} else if (buf[2] == '1' && buf[3] == ':') {
// 201. Field data
nsCOMPtr<nsIDirIndex> idx = do_CreateInstance("@mozilla.org/dirIndex;1",&rv);
if (NS_FAILED(rv))
return rv;
rv = ParseData(idx, ((char *)buf) + 4, lineLen - 4);
if (NS_FAILED(rv)) {
return rv;
}
mListener->OnIndexAvailable(aRequest, aCtxt, idx);
}
}
} else if (buf[0] == '3') {
if (buf[1] == '0') {
if (buf[2] == '0' && buf[3] == ':') {
// 300. Self-referring URL
} else if (buf[2] == '1' && buf[3] == ':') {
// 301. OUR EXTENSION - encoding
int i = 4;
while (buf[i] && nsCRT::IsAsciiSpace(buf[i]))
++i;
if (buf[i])
SetEncoding(buf+i);
}
}
}
}
}
return NS_OK;
}

View file

@ -0,0 +1,67 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef __NSDIRINDEX_H_
#define __NSDIRINDEX_H_
#include "nsString.h"
#include "nsCOMPtr.h"
#include "nsIDirIndexListener.h"
class nsIDirIndex;
class nsITextToSubURI;
/* CID: {a0d6ad32-1dd1-11b2-aa55-a40187b54036} */
class nsDirIndexParser : public nsIDirIndexParser {
private:
virtual ~nsDirIndexParser();
public:
NS_DECL_ISUPPORTS
NS_DECL_NSISTREAMLISTENER
NS_DECL_NSIREQUESTOBSERVER
NS_DECL_NSIDIRINDEXPARSER
nsDirIndexParser();
nsresult Init();
enum fieldType {
FIELD_UNKNOWN = 0, // MUST be 0
FIELD_FILENAME,
FIELD_DESCRIPTION,
FIELD_CONTENTLENGTH,
FIELD_LASTMODIFIED,
FIELD_CONTENTTYPE,
FIELD_FILETYPE
};
protected:
nsCOMPtr<nsIDirIndexListener> mListener;
nsCString mEncoding;
nsCString mComment;
nsCString mBuf;
int32_t mLineStart;
bool mHasDescription;
int mFormat[8];
nsresult ProcessData(nsIRequest *aRequest, nsISupports *aCtxt);
nsresult ParseFormat(const char* buf);
nsresult ParseData(nsIDirIndex* aIdx, char* aDataStr, int32_t lineLen);
struct Field {
const char *mName;
fieldType mType;
};
static Field gFieldTable[];
static nsrefcnt gRefCntParser;
static nsITextToSubURI* gTextToSubURI;
};
#endif

View file

@ -0,0 +1,345 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsFTPDirListingConv.h"
#include "nsMemory.h"
#include "plstr.h"
#include "mozilla/Logging.h"
#include "nsCOMPtr.h"
#include "nsEscape.h"
#include "nsStringStream.h"
#include "nsIStreamListener.h"
#include "nsCRT.h"
#include "nsIChannel.h"
#include "nsIURI.h"
#include "ParseFTPList.h"
#include <algorithm>
#include "mozilla/UniquePtrExtensions.h"
#include "mozilla/Unused.h"
//
// Log module for FTP dir listing stream converter logging...
//
// To enable logging (see prlog.h for full details):
//
// set MOZ_LOG=nsFTPDirListConv:5
// set MOZ_LOG_FILE=network.log
//
// This enables LogLevel::Debug level information and places all output in
// the file network.log.
//
static mozilla::LazyLogModule gFTPDirListConvLog("nsFTPDirListingConv");
using namespace mozilla;
// nsISupports implementation
NS_IMPL_ISUPPORTS(nsFTPDirListingConv,
nsIStreamConverter,
nsIStreamListener,
nsIRequestObserver)
// nsIStreamConverter implementation
NS_IMETHODIMP
nsFTPDirListingConv::Convert(nsIInputStream *aFromStream,
const char *aFromType,
const char *aToType,
nsISupports *aCtxt, nsIInputStream **_retval) {
return NS_ERROR_NOT_IMPLEMENTED;
}
// Stream converter service calls this to initialize the actual stream converter (us).
NS_IMETHODIMP
nsFTPDirListingConv::AsyncConvertData(const char *aFromType, const char *aToType,
nsIStreamListener *aListener, nsISupports *aCtxt) {
NS_ASSERTION(aListener && aFromType && aToType, "null pointer passed into FTP dir listing converter");
// hook up our final listener. this guy gets the various On*() calls we want to throw
// at him.
mFinalListener = aListener;
NS_ADDREF(mFinalListener);
MOZ_LOG(gFTPDirListConvLog, LogLevel::Debug,
("nsFTPDirListingConv::AsyncConvertData() converting FROM raw, TO application/http-index-format\n"));
return NS_OK;
}
// nsIStreamListener implementation
NS_IMETHODIMP
nsFTPDirListingConv::OnDataAvailable(nsIRequest* request, nsISupports *ctxt,
nsIInputStream *inStr, uint64_t sourceOffset, uint32_t count) {
NS_ASSERTION(request, "FTP dir listing stream converter needs a request");
nsresult rv;
nsCOMPtr<nsIChannel> channel = do_QueryInterface(request, &rv);
NS_ENSURE_SUCCESS(rv, rv);
uint32_t read, streamLen;
uint64_t streamLen64;
rv = inStr->Available(&streamLen64);
NS_ENSURE_SUCCESS(rv, rv);
streamLen = (uint32_t)std::min(streamLen64, uint64_t(UINT32_MAX - 1));
auto buffer = MakeUniqueFallible<char[]>(streamLen + 1);
NS_ENSURE_TRUE(buffer, NS_ERROR_OUT_OF_MEMORY);
rv = inStr->Read(buffer.get(), streamLen, &read);
NS_ENSURE_SUCCESS(rv, rv);
// the dir listings are ascii text, null terminate this sucker.
buffer[streamLen] = '\0';
MOZ_LOG(gFTPDirListConvLog, LogLevel::Debug, ("nsFTPDirListingConv::OnData(request = %x, ctxt = %x, inStr = %x, sourceOffset = %llu, count = %u)\n", request, ctxt, inStr, sourceOffset, count));
if (!mBuffer.IsEmpty()) {
// we have data left over from a previous OnDataAvailable() call.
// combine the buffers so we don't lose any data.
mBuffer.Append(buffer.get());
buffer = MakeUniqueFallible<char[]>(mBuffer.Length()+1);
NS_ENSURE_TRUE(buffer, NS_ERROR_OUT_OF_MEMORY);
strncpy(buffer.get(), mBuffer.get(), mBuffer.Length()+1);
mBuffer.Truncate();
}
MOZ_LOG(gFTPDirListConvLog, LogLevel::Debug, ("::OnData() received the following %d bytes...\n\n%s\n\n", streamLen, buffer.get()) );
nsAutoCString indexFormat;
if (!mSentHeading) {
// build up the 300: line
nsCOMPtr<nsIURI> uri;
rv = channel->GetURI(getter_AddRefs(uri));
NS_ENSURE_SUCCESS(rv, rv);
rv = GetHeaders(indexFormat, uri);
NS_ENSURE_SUCCESS(rv, rv);
mSentHeading = true;
}
char *line = buffer.get();
line = DigestBufferLines(line, indexFormat);
MOZ_LOG(gFTPDirListConvLog, LogLevel::Debug, ("::OnData() sending the following %d bytes...\n\n%s\n\n",
indexFormat.Length(), indexFormat.get()) );
// if there's any data left over, buffer it.
if (line && *line) {
mBuffer.Append(line);
MOZ_LOG(gFTPDirListConvLog, LogLevel::Debug, ("::OnData() buffering the following %d bytes...\n\n%s\n\n",
strlen(line), line) );
}
// send the converted data out.
nsCOMPtr<nsIInputStream> inputData;
rv = NS_NewCStringInputStream(getter_AddRefs(inputData), indexFormat);
NS_ENSURE_SUCCESS(rv, rv);
rv = mFinalListener->OnDataAvailable(request, ctxt, inputData, 0, indexFormat.Length());
return rv;
}
// nsIRequestObserver implementation
NS_IMETHODIMP
nsFTPDirListingConv::OnStartRequest(nsIRequest* request, nsISupports *ctxt) {
// we don't care about start. move along... but start masqeurading
// as the http-index channel now.
return mFinalListener->OnStartRequest(request, ctxt);
}
NS_IMETHODIMP
nsFTPDirListingConv::OnStopRequest(nsIRequest* request, nsISupports *ctxt,
nsresult aStatus) {
// we don't care about stop. move along...
return mFinalListener->OnStopRequest(request, ctxt, aStatus);
}
// nsFTPDirListingConv methods
nsFTPDirListingConv::nsFTPDirListingConv() {
mFinalListener = nullptr;
mSentHeading = false;
}
nsFTPDirListingConv::~nsFTPDirListingConv() {
NS_IF_RELEASE(mFinalListener);
}
nsresult
nsFTPDirListingConv::GetHeaders(nsACString& headers,
nsIURI* uri)
{
nsresult rv = NS_OK;
// build up 300 line
headers.AppendLiteral("300: ");
// Bug 111117 - don't print the password
nsAutoCString pw;
nsAutoCString spec;
uri->GetPassword(pw);
if (!pw.IsEmpty()) {
rv = uri->SetPassword(EmptyCString());
if (NS_FAILED(rv)) return rv;
rv = uri->GetAsciiSpec(spec);
if (NS_FAILED(rv)) return rv;
headers.Append(spec);
rv = uri->SetPassword(pw);
if (NS_FAILED(rv)) return rv;
} else {
rv = uri->GetAsciiSpec(spec);
if (NS_FAILED(rv)) return rv;
headers.Append(spec);
}
headers.Append(char(nsCRT::LF));
// END 300:
// build up the column heading; 200:
headers.AppendLiteral("200: filename content-length last-modified file-type\n");
// END 200:
return rv;
}
char *
nsFTPDirListingConv::DigestBufferLines(char *aBuffer, nsCString &aString) {
char *line = aBuffer;
char *eol;
bool cr = false;
list_state state;
// while we have new lines, parse 'em into application/http-index-format.
while ( line && (eol = PL_strchr(line, nsCRT::LF)) ) {
// yank any carriage returns too.
if (eol > line && *(eol-1) == nsCRT::CR) {
eol--;
*eol = '\0';
cr = true;
} else {
*eol = '\0';
cr = false;
}
list_result result;
int type = ParseFTPList(line, &state, &result );
// if it is other than a directory, file, or link -OR- if it is a
// directory named . or .., skip over this line.
if ((type != 'd' && type != 'f' && type != 'l') ||
(result.fe_type == 'd' && result.fe_fname[0] == '.' &&
(result.fe_fnlen == 1 || (result.fe_fnlen == 2 && result.fe_fname[1] == '.'))) )
{
if (cr)
line = eol+2;
else
line = eol+1;
continue;
}
// blast the index entry into the indexFormat buffer as a 201: line.
aString.AppendLiteral("201: ");
// FILENAME
// parsers for styles 'U' and 'W' handle sequence " -> " themself
if (state.lstyle != 'U' && state.lstyle != 'W') {
const char* offset = strstr(result.fe_fname, " -> ");
if (offset) {
result.fe_fnlen = offset - result.fe_fname;
}
}
nsAutoCString buf;
aString.Append('\"');
aString.Append(NS_EscapeURL(Substring(result.fe_fname,
result.fe_fname+result.fe_fnlen),
esc_Minimal|esc_OnlyASCII|esc_Forced,buf));
aString.AppendLiteral("\" ");
// CONTENT LENGTH
if (type != 'd')
{
for (int i = 0; i < int(sizeof(result.fe_size)); ++i)
{
if (result.fe_size[i] != '\0')
aString.Append((const char*)&result.fe_size[i], 1);
}
aString.Append(' ');
}
else
aString.AppendLiteral("0 ");
// MODIFIED DATE
char buffer[256] = "";
// ParseFTPList can return time structure with invalid values.
// PR_NormalizeTime will set all values into valid limits.
result.fe_time.tm_params.tp_gmt_offset = 0;
result.fe_time.tm_params.tp_dst_offset = 0;
PR_NormalizeTime(&result.fe_time, PR_GMTParameters);
// Note: The below is the RFC822/1123 format, as required by
// the application/http-index-format specs
// viewers of such a format can then reformat this into the
// current locale (or anything else they choose)
PR_FormatTimeUSEnglish(buffer, sizeof(buffer),
"%a, %d %b %Y %H:%M:%S", &result.fe_time );
nsAutoCString escaped;
Unused << NS_WARN_IF(!NS_Escape(nsDependentCString(buffer), escaped, url_Path));
aString.Append(escaped);
aString.Append(' ');
// ENTRY TYPE
if (type == 'd')
aString.AppendLiteral("DIRECTORY");
else if (type == 'l')
aString.AppendLiteral("SYMBOLIC-LINK");
else
aString.AppendLiteral("FILE");
aString.Append(' ');
aString.Append(char(nsCRT::LF)); // complete this line
// END 201:
if (cr)
line = eol+2;
else
line = eol+1;
} // end while(eol)
return line;
}
nsresult
NS_NewFTPDirListingConv(nsFTPDirListingConv** aFTPDirListingConv)
{
NS_PRECONDITION(aFTPDirListingConv != nullptr, "null ptr");
if (! aFTPDirListingConv)
return NS_ERROR_NULL_POINTER;
*aFTPDirListingConv = new nsFTPDirListingConv();
if (! *aFTPDirListingConv)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(*aFTPDirListingConv);
return NS_OK;
}

View file

@ -0,0 +1,52 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef __nsftpdirlistingdconv__h__
#define __nsftpdirlistingdconv__h__
#include "nsIStreamConverter.h"
#include "nsString.h"
class nsIURI;
#define NS_FTPDIRLISTINGCONVERTER_CID \
{ /* 14C0E880-623E-11d3-A178-0050041CAF44 */ \
0x14c0e880, \
0x623e, \
0x11d3, \
{0xa1, 0x78, 0x00, 0x50, 0x04, 0x1c, 0xaf, 0x44} \
}
class nsFTPDirListingConv : public nsIStreamConverter {
public:
// nsISupports methods
NS_DECL_ISUPPORTS
// nsIStreamConverter methods
NS_DECL_NSISTREAMCONVERTER
// nsIStreamListener methods
NS_DECL_NSISTREAMLISTENER
// nsIRequestObserver methods
NS_DECL_NSIREQUESTOBSERVER
// nsFTPDirListingConv methods
nsFTPDirListingConv();
private:
virtual ~nsFTPDirListingConv();
// Get the application/http-index-format headers
nsresult GetHeaders(nsACString& str, nsIURI* uri);
char* DigestBufferLines(char *aBuffer, nsCString &aString);
// member data
nsCString mBuffer; // buffered data.
bool mSentHeading; // have we sent 100, 101, 200, and 300 lines yet?
nsIStreamListener *mFinalListener; // this guy gets the converted data via his OnDataAvailable()
};
#endif /* __nsftpdirlistingdconv__h__ */

View file

@ -0,0 +1,659 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set sw=2 ts=8 et tw=80 : */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsHTTPCompressConv.h"
#include "nsMemory.h"
#include "plstr.h"
#include "nsCOMPtr.h"
#include "nsError.h"
#include "nsStreamUtils.h"
#include "nsStringStream.h"
#include "nsComponentManagerUtils.h"
#include "nsThreadUtils.h"
#include "mozilla/Preferences.h"
#include "mozilla/Logging.h"
#include "nsIForcePendingChannel.h"
#include "nsIRequest.h"
// brotli headers
#include "state.h"
#include "decode.h"
namespace mozilla {
namespace net {
extern LazyLogModule gHttpLog;
#define LOG(args) MOZ_LOG(mozilla::net::gHttpLog, mozilla::LogLevel::Debug, args)
// nsISupports implementation
NS_IMPL_ISUPPORTS(nsHTTPCompressConv,
nsIStreamConverter,
nsIStreamListener,
nsIRequestObserver,
nsICompressConvStats)
// nsFTPDirListingConv methods
nsHTTPCompressConv::nsHTTPCompressConv()
: mMode(HTTP_COMPRESS_IDENTITY)
, mOutBuffer(nullptr)
, mInpBuffer(nullptr)
, mOutBufferLen(0)
, mInpBufferLen(0)
, mCheckHeaderDone(false)
, mStreamEnded(false)
, mStreamInitialized(false)
, mLen(0)
, hMode(0)
, mSkipCount(0)
, mFlags(0)
, mDecodedDataLength(0)
{
LOG(("nsHttpCompresssConv %p ctor\n", this));
if (NS_IsMainThread()) {
mFailUncleanStops =
Preferences::GetBool("network.http.enforce-framing.http", false);
} else {
mFailUncleanStops = false;
}
}
nsHTTPCompressConv::~nsHTTPCompressConv()
{
LOG(("nsHttpCompresssConv %p dtor\n", this));
if (mInpBuffer) {
free(mInpBuffer);
}
if (mOutBuffer) {
free(mOutBuffer);
}
// For some reason we are not getting Z_STREAM_END. But this was also seen
// for mozilla bug 198133. Need to handle this case.
if (mStreamInitialized && !mStreamEnded) {
inflateEnd (&d_stream);
}
}
NS_IMETHODIMP
nsHTTPCompressConv::GetDecodedDataLength(uint64_t *aDecodedDataLength)
{
*aDecodedDataLength = mDecodedDataLength;
return NS_OK;
}
NS_IMETHODIMP
nsHTTPCompressConv::AsyncConvertData(const char *aFromType,
const char *aToType,
nsIStreamListener *aListener,
nsISupports *aCtxt)
{
if (!PL_strncasecmp(aFromType, HTTP_COMPRESS_TYPE, sizeof(HTTP_COMPRESS_TYPE)-1) ||
!PL_strncasecmp(aFromType, HTTP_X_COMPRESS_TYPE, sizeof(HTTP_X_COMPRESS_TYPE)-1)) {
mMode = HTTP_COMPRESS_COMPRESS;
} else if (!PL_strncasecmp(aFromType, HTTP_GZIP_TYPE, sizeof(HTTP_GZIP_TYPE)-1) ||
!PL_strncasecmp(aFromType, HTTP_X_GZIP_TYPE, sizeof(HTTP_X_GZIP_TYPE)-1)) {
mMode = HTTP_COMPRESS_GZIP;
} else if (!PL_strncasecmp(aFromType, HTTP_DEFLATE_TYPE, sizeof(HTTP_DEFLATE_TYPE)-1)) {
mMode = HTTP_COMPRESS_DEFLATE;
} else if (!PL_strncasecmp(aFromType, HTTP_BROTLI_TYPE, sizeof(HTTP_BROTLI_TYPE)-1)) {
mMode = HTTP_COMPRESS_BROTLI;
}
LOG(("nsHttpCompresssConv %p AsyncConvertData %s %s mode %d\n",
this, aFromType, aToType, mMode));
// hook ourself up with the receiving listener.
mListener = aListener;
mAsyncConvContext = aCtxt;
return NS_OK;
}
NS_IMETHODIMP
nsHTTPCompressConv::OnStartRequest(nsIRequest* request, nsISupports *aContext)
{
LOG(("nsHttpCompresssConv %p onstart\n", this));
return mListener->OnStartRequest(request, aContext);
}
NS_IMETHODIMP
nsHTTPCompressConv::OnStopRequest(nsIRequest* request, nsISupports *aContext,
nsresult aStatus)
{
nsresult status = aStatus;
LOG(("nsHttpCompresssConv %p onstop %x\n", this, aStatus));
// Framing integrity is enforced for content-encoding: gzip, but not for
// content-encoding: deflate. Note that gzip vs deflate is NOT determined
// by content sniffing but only via header.
if (!mStreamEnded && NS_SUCCEEDED(status) &&
(mFailUncleanStops && (mMode == HTTP_COMPRESS_GZIP)) ) {
// This is not a clean end of gzip stream: the transfer is incomplete.
status = NS_ERROR_NET_PARTIAL_TRANSFER;
LOG(("nsHttpCompresssConv %p onstop partial gzip\n", this));
}
if (NS_SUCCEEDED(status) && mMode == HTTP_COMPRESS_BROTLI) {
nsCOMPtr<nsIForcePendingChannel> fpChannel = do_QueryInterface(request);
bool isPending = false;
if (request) {
request->IsPending(&isPending);
}
if (fpChannel && !isPending) {
fpChannel->ForcePending(true);
}
if (mBrotli && (mBrotli->mTotalOut == 0) && !BrotliStateIsStreamEnd(&mBrotli->mState)) {
status = NS_ERROR_INVALID_CONTENT_ENCODING;
}
LOG(("nsHttpCompresssConv %p onstop brotlihandler rv %x\n", this, status));
if (fpChannel && !isPending) {
fpChannel->ForcePending(false);
}
}
return mListener->OnStopRequest(request, aContext, status);
}
/* static */ nsresult
nsHTTPCompressConv::BrotliHandler(nsIInputStream *stream, void *closure, const char *dataIn,
uint32_t, uint32_t aAvail, uint32_t *countRead)
{
MOZ_ASSERT(stream);
nsHTTPCompressConv *self = static_cast<nsHTTPCompressConv *>(closure);
*countRead = 0;
const size_t kOutSize = 128 * 1024; // just a chunk size, we call in a loop
uint8_t *outPtr;
size_t outSize;
size_t avail = aAvail;
BrotliResult res;
if (!self->mBrotli) {
*countRead = aAvail;
return NS_OK;
}
auto outBuffer = MakeUniqueFallible<uint8_t[]>(kOutSize);
if (outBuffer == nullptr) {
self->mBrotli->mStatus = NS_ERROR_OUT_OF_MEMORY;
return self->mBrotli->mStatus;
}
do {
outSize = kOutSize;
outPtr = outBuffer.get();
// brotli api is documented in brotli/dec/decode.h and brotli/dec/decode.c
LOG(("nsHttpCompresssConv %p brotlihandler decompress %d\n", self, avail));
res = ::BrotliDecompressStream(
&avail, reinterpret_cast<const unsigned char **>(&dataIn),
&outSize, &outPtr, &self->mBrotli->mTotalOut, &self->mBrotli->mState);
outSize = kOutSize - outSize;
LOG(("nsHttpCompresssConv %p brotlihandler decompress rv=%x out=%d\n",
self, res, outSize));
if (res == BROTLI_RESULT_ERROR) {
LOG(("nsHttpCompressConv %p marking invalid encoding", self));
self->mBrotli->mStatus = NS_ERROR_INVALID_CONTENT_ENCODING;
return self->mBrotli->mStatus;
}
// in 'the current implementation' brotli must consume everything before
// asking for more input
if (res == BROTLI_RESULT_NEEDS_MORE_INPUT) {
MOZ_ASSERT(!avail);
if (avail) {
LOG(("nsHttpCompressConv %p did not consume all input", self));
self->mBrotli->mStatus = NS_ERROR_UNEXPECTED;
return self->mBrotli->mStatus;
}
}
if (outSize > 0) {
nsresult rv = self->do_OnDataAvailable(self->mBrotli->mRequest,
self->mBrotli->mContext,
self->mBrotli->mSourceOffset,
reinterpret_cast<const char *>(outBuffer.get()),
outSize);
LOG(("nsHttpCompressConv %p BrotliHandler ODA rv=%x", self, rv));
if (NS_FAILED(rv)) {
self->mBrotli->mStatus = rv;
return self->mBrotli->mStatus;
}
}
if (res == BROTLI_RESULT_SUCCESS ||
res == BROTLI_RESULT_NEEDS_MORE_INPUT) {
*countRead = aAvail;
return NS_OK;
}
MOZ_ASSERT (res == BROTLI_RESULT_NEEDS_MORE_OUTPUT);
} while (res == BROTLI_RESULT_NEEDS_MORE_OUTPUT);
self->mBrotli->mStatus = NS_ERROR_UNEXPECTED;
return self->mBrotli->mStatus;
}
NS_IMETHODIMP
nsHTTPCompressConv::OnDataAvailable(nsIRequest* request,
nsISupports *aContext,
nsIInputStream *iStr,
uint64_t aSourceOffset,
uint32_t aCount)
{
nsresult rv = NS_ERROR_INVALID_CONTENT_ENCODING;
uint32_t streamLen = aCount;
LOG(("nsHttpCompressConv %p OnDataAvailable %d", this, aCount));
if (streamLen == 0) {
NS_ERROR("count of zero passed to OnDataAvailable");
return NS_ERROR_UNEXPECTED;
}
if (mStreamEnded) {
// Hmm... this may just indicate that the data stream is done and that
// what's left is either metadata or padding of some sort.... throwing
// it out is probably the safe thing to do.
uint32_t n;
return iStr->ReadSegments(NS_DiscardSegment, nullptr, streamLen, &n);
}
switch (mMode) {
case HTTP_COMPRESS_GZIP:
streamLen = check_header(iStr, streamLen, &rv);
if (rv != NS_OK) {
return rv;
}
if (streamLen == 0) {
return NS_OK;
}
MOZ_FALLTHROUGH;
case HTTP_COMPRESS_DEFLATE:
if (mInpBuffer != nullptr && streamLen > mInpBufferLen) {
mInpBuffer = (unsigned char *) realloc(mInpBuffer, mInpBufferLen = streamLen);
if (mOutBufferLen < streamLen * 2) {
mOutBuffer = (unsigned char *) realloc(mOutBuffer, mOutBufferLen = streamLen * 3);
}
if (mInpBuffer == nullptr || mOutBuffer == nullptr) {
return NS_ERROR_OUT_OF_MEMORY;
}
}
if (mInpBuffer == nullptr) {
mInpBuffer = (unsigned char *) malloc(mInpBufferLen = streamLen);
}
if (mOutBuffer == nullptr) {
mOutBuffer = (unsigned char *) malloc(mOutBufferLen = streamLen * 3);
}
if (mInpBuffer == nullptr || mOutBuffer == nullptr) {
return NS_ERROR_OUT_OF_MEMORY;
}
uint32_t unused;
iStr->Read((char *)mInpBuffer, streamLen, &unused);
if (mMode == HTTP_COMPRESS_DEFLATE) {
if (!mStreamInitialized) {
memset(&d_stream, 0, sizeof (d_stream));
if (inflateInit(&d_stream) != Z_OK) {
return NS_ERROR_FAILURE;
}
mStreamInitialized = true;
}
d_stream.next_in = mInpBuffer;
d_stream.avail_in = (uInt)streamLen;
mDummyStreamInitialised = false;
for (;;) {
d_stream.next_out = mOutBuffer;
d_stream.avail_out = (uInt)mOutBufferLen;
int code = inflate(&d_stream, Z_NO_FLUSH);
unsigned bytesWritten = (uInt)mOutBufferLen - d_stream.avail_out;
if (code == Z_STREAM_END) {
if (bytesWritten) {
rv = do_OnDataAvailable(request, aContext, aSourceOffset, (char *)mOutBuffer, bytesWritten);
if (NS_FAILED (rv)) {
return rv;
}
}
inflateEnd(&d_stream);
mStreamEnded = true;
break;
} else if (code == Z_OK) {
if (bytesWritten) {
rv = do_OnDataAvailable(request, aContext, aSourceOffset, (char *)mOutBuffer, bytesWritten);
if (NS_FAILED (rv)) {
return rv;
}
}
} else if (code == Z_BUF_ERROR) {
if (bytesWritten) {
rv = do_OnDataAvailable(request, aContext, aSourceOffset, (char *)mOutBuffer, bytesWritten);
if (NS_FAILED (rv)) {
return rv;
}
}
break;
} else if (code == Z_DATA_ERROR) {
// some servers (notably Apache with mod_deflate) don't generate zlib headers
// insert a dummy header and try again
static char dummy_head[2] =
{
0x8 + 0x7 * 0x10,
(((0x8 + 0x7 * 0x10) * 0x100 + 30) / 31 * 31) & 0xFF,
};
inflateReset(&d_stream);
d_stream.next_in = (Bytef*) dummy_head;
d_stream.avail_in = sizeof(dummy_head);
code = inflate(&d_stream, Z_NO_FLUSH);
if (code != Z_OK) {
return NS_ERROR_FAILURE;
}
// stop an endless loop caused by non-deflate data being labelled as deflate
if (mDummyStreamInitialised) {
NS_WARNING("endless loop detected"
" - invalid deflate");
return NS_ERROR_INVALID_CONTENT_ENCODING;
}
mDummyStreamInitialised = true;
// reset stream pointers to our original data
d_stream.next_in = mInpBuffer;
d_stream.avail_in = (uInt)streamLen;
} else {
return NS_ERROR_INVALID_CONTENT_ENCODING;
}
} /* for */
} else {
if (!mStreamInitialized) {
memset(&d_stream, 0, sizeof (d_stream));
if (inflateInit2(&d_stream, -MAX_WBITS) != Z_OK) {
return NS_ERROR_FAILURE;
}
mStreamInitialized = true;
}
d_stream.next_in = mInpBuffer;
d_stream.avail_in = (uInt)streamLen;
for (;;) {
d_stream.next_out = mOutBuffer;
d_stream.avail_out = (uInt)mOutBufferLen;
int code = inflate (&d_stream, Z_NO_FLUSH);
unsigned bytesWritten = (uInt)mOutBufferLen - d_stream.avail_out;
if (code == Z_STREAM_END) {
if (bytesWritten) {
rv = do_OnDataAvailable(request, aContext, aSourceOffset, (char *)mOutBuffer, bytesWritten);
if (NS_FAILED (rv)) {
return rv;
}
}
inflateEnd(&d_stream);
mStreamEnded = true;
break;
} else if (code == Z_OK) {
if (bytesWritten) {
rv = do_OnDataAvailable(request, aContext, aSourceOffset, (char *)mOutBuffer, bytesWritten);
if (NS_FAILED (rv)) {
return rv;
}
}
} else if (code == Z_BUF_ERROR) {
if (bytesWritten) {
rv = do_OnDataAvailable(request, aContext, aSourceOffset, (char *)mOutBuffer, bytesWritten);
if (NS_FAILED (rv)) {
return rv;
}
}
break;
} else {
return NS_ERROR_INVALID_CONTENT_ENCODING;
}
} /* for */
} /* gzip */
break;
case HTTP_COMPRESS_BROTLI:
{
if (!mBrotli) {
mBrotli = new BrotliWrapper();
}
mBrotli->mRequest = request;
mBrotli->mContext = aContext;
mBrotli->mSourceOffset = aSourceOffset;
uint32_t countRead;
rv = iStr->ReadSegments(BrotliHandler, this, streamLen, &countRead);
if (NS_SUCCEEDED(rv)) {
rv = mBrotli->mStatus;
}
if (NS_FAILED(rv)) {
return rv;
}
}
break;
default:
rv = mListener->OnDataAvailable(request, aContext, iStr, aSourceOffset, aCount);
if (NS_FAILED (rv)) {
return rv;
}
} /* switch */
return NS_OK;
} /* OnDataAvailable */
// XXX/ruslan: need to implement this too
NS_IMETHODIMP
nsHTTPCompressConv::Convert(nsIInputStream *aFromStream,
const char *aFromType,
const char *aToType,
nsISupports *aCtxt,
nsIInputStream **_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
nsresult
nsHTTPCompressConv::do_OnDataAvailable(nsIRequest* request,
nsISupports *context, uint64_t offset,
const char *buffer, uint32_t count)
{
if (!mStream) {
mStream = do_CreateInstance(NS_STRINGINPUTSTREAM_CONTRACTID);
NS_ENSURE_STATE(mStream);
}
mStream->ShareData(buffer, count);
nsresult rv = mListener->OnDataAvailable(request, context, mStream,
offset, count);
// Make sure the stream no longer references |buffer| in case our listener
// is crazy enough to try to read from |mStream| after ODA.
mStream->ShareData("", 0);
mDecodedDataLength += count;
return rv;
}
#define ASCII_FLAG 0x01 /* bit 0 set: file probably ascii text */
#define HEAD_CRC 0x02 /* bit 1 set: header CRC present */
#define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */
#define ORIG_NAME 0x08 /* bit 3 set: original file name present */
#define COMMENT 0x10 /* bit 4 set: file comment present */
#define RESERVED 0xE0 /* bits 5..7: reserved */
static unsigned gz_magic[2] = {0x1f, 0x8b}; /* gzip magic header */
uint32_t
nsHTTPCompressConv::check_header(nsIInputStream *iStr, uint32_t streamLen, nsresult *rs)
{
enum { GZIP_INIT = 0, GZIP_OS, GZIP_EXTRA0, GZIP_EXTRA1, GZIP_EXTRA2, GZIP_ORIG, GZIP_COMMENT, GZIP_CRC };
char c;
*rs = NS_OK;
if (mCheckHeaderDone) {
return streamLen;
}
while (streamLen) {
switch (hMode) {
case GZIP_INIT:
uint32_t unused;
iStr->Read(&c, 1, &unused);
streamLen--;
if (mSkipCount == 0 && ((unsigned)c & 0377) != gz_magic[0]) {
*rs = NS_ERROR_INVALID_CONTENT_ENCODING;
return 0;
}
if (mSkipCount == 1 && ((unsigned)c & 0377) != gz_magic[1]) {
*rs = NS_ERROR_INVALID_CONTENT_ENCODING;
return 0;
}
if (mSkipCount == 2 && ((unsigned)c & 0377) != Z_DEFLATED) {
*rs = NS_ERROR_INVALID_CONTENT_ENCODING;
return 0;
}
mSkipCount++;
if (mSkipCount == 4) {
mFlags = (unsigned) c & 0377;
if (mFlags & RESERVED) {
*rs = NS_ERROR_INVALID_CONTENT_ENCODING;
return 0;
}
hMode = GZIP_OS;
mSkipCount = 0;
}
break;
case GZIP_OS:
iStr->Read(&c, 1, &unused);
streamLen--;
mSkipCount++;
if (mSkipCount == 6) {
hMode = GZIP_EXTRA0;
}
break;
case GZIP_EXTRA0:
if (mFlags & EXTRA_FIELD) {
iStr->Read(&c, 1, &unused);
streamLen--;
mLen = (uInt) c & 0377;
hMode = GZIP_EXTRA1;
} else {
hMode = GZIP_ORIG;
}
break;
case GZIP_EXTRA1:
iStr->Read(&c, 1, &unused);
streamLen--;
mLen |= ((uInt) c & 0377) << 8;
mSkipCount = 0;
hMode = GZIP_EXTRA2;
break;
case GZIP_EXTRA2:
if (mSkipCount == mLen) {
hMode = GZIP_ORIG;
} else {
iStr->Read(&c, 1, &unused);
streamLen--;
mSkipCount++;
}
break;
case GZIP_ORIG:
if (mFlags & ORIG_NAME) {
iStr->Read(&c, 1, &unused);
streamLen--;
if (c == 0)
hMode = GZIP_COMMENT;
} else {
hMode = GZIP_COMMENT;
}
break;
case GZIP_COMMENT:
if (mFlags & COMMENT) {
iStr->Read(&c, 1, &unused);
streamLen--;
if (c == 0) {
hMode = GZIP_CRC;
mSkipCount = 0;
}
} else {
hMode = GZIP_CRC;
mSkipCount = 0;
}
break;
case GZIP_CRC:
if (mFlags & HEAD_CRC) {
iStr->Read(&c, 1, &unused);
streamLen--;
mSkipCount++;
if (mSkipCount == 2) {
mCheckHeaderDone = true;
return streamLen;
}
} else {
mCheckHeaderDone = true;
return streamLen;
}
break;
}
}
return streamLen;
}
} // namespace net
} // namespace mozilla
nsresult
NS_NewHTTPCompressConv(mozilla::net::nsHTTPCompressConv **aHTTPCompressConv)
{
NS_PRECONDITION(aHTTPCompressConv != nullptr, "null ptr");
if (!aHTTPCompressConv) {
return NS_ERROR_NULL_POINTER;
}
RefPtr<mozilla::net::nsHTTPCompressConv> outVal =
new mozilla::net::nsHTTPCompressConv();
if (!outVal) {
return NS_ERROR_OUT_OF_MEMORY;
}
outVal.forget(aHTTPCompressConv);
return NS_OK;
}

View file

@ -0,0 +1,135 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set sw=2 ts=8 et tw=80 : */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#if !defined (__nsHTTPCompressConv__h__)
#define __nsHTTPCompressConv__h__ 1
#include "nsIStreamConverter.h"
#include "nsICompressConvStats.h"
#include "nsCOMPtr.h"
#include "nsAutoPtr.h"
#include "zlib.h"
// brotli includes
#undef assert
#include "assert.h"
#include "state.h"
class nsIStringInputStream;
#define NS_HTTPCOMPRESSCONVERTER_CID \
{ \
/* 66230b2b-17fa-4bd3-abf4-07986151022d */ \
0x66230b2b, \
0x17fa, \
0x4bd3, \
{0xab, 0xf4, 0x07, 0x98, 0x61, 0x51, 0x02, 0x2d} \
}
#define HTTP_DEFLATE_TYPE "deflate"
#define HTTP_GZIP_TYPE "gzip"
#define HTTP_X_GZIP_TYPE "x-gzip"
#define HTTP_COMPRESS_TYPE "compress"
#define HTTP_X_COMPRESS_TYPE "x-compress"
#define HTTP_BROTLI_TYPE "br"
#define HTTP_IDENTITY_TYPE "identity"
#define HTTP_UNCOMPRESSED_TYPE "uncompressed"
namespace mozilla {
namespace net {
typedef enum {
HTTP_COMPRESS_GZIP,
HTTP_COMPRESS_DEFLATE,
HTTP_COMPRESS_COMPRESS,
HTTP_COMPRESS_BROTLI,
HTTP_COMPRESS_IDENTITY
} CompressMode;
class BrotliWrapper
{
public:
BrotliWrapper()
: mTotalOut(0)
, mStatus(NS_OK)
{
BrotliStateInit(&mState);
}
~BrotliWrapper()
{
BrotliStateCleanup(&mState);
}
BrotliState mState;
size_t mTotalOut;
nsresult mStatus;
nsIRequest *mRequest;
nsISupports *mContext;
uint64_t mSourceOffset;
};
class nsHTTPCompressConv
: public nsIStreamConverter
, public nsICompressConvStats
{
public:
// nsISupports methods
NS_DECL_THREADSAFE_ISUPPORTS
NS_DECL_NSIREQUESTOBSERVER
NS_DECL_NSISTREAMLISTENER
NS_DECL_NSICOMPRESSCONVSTATS
// nsIStreamConverter methods
NS_DECL_NSISTREAMCONVERTER
nsHTTPCompressConv ();
private:
virtual ~nsHTTPCompressConv ();
nsCOMPtr<nsIStreamListener> mListener; // this guy gets the converted data via his OnDataAvailable ()
CompressMode mMode;
unsigned char *mOutBuffer;
unsigned char *mInpBuffer;
uint32_t mOutBufferLen;
uint32_t mInpBufferLen;
nsAutoPtr<BrotliWrapper> mBrotli;
nsCOMPtr<nsISupports> mAsyncConvContext;
nsCOMPtr<nsIStringInputStream> mStream;
static nsresult
BrotliHandler(nsIInputStream *stream, void *closure, const char *dataIn,
uint32_t, uint32_t avail, uint32_t *countRead);
nsresult do_OnDataAvailable (nsIRequest *request, nsISupports *aContext,
uint64_t aSourceOffset, const char *buffer,
uint32_t aCount);
bool mCheckHeaderDone;
bool mStreamEnded;
bool mStreamInitialized;
bool mDummyStreamInitialised;
bool mFailUncleanStops;
z_stream d_stream;
unsigned mLen, hMode, mSkipCount, mFlags;
uint32_t check_header (nsIInputStream *iStr, uint32_t streamLen, nsresult *rv);
uint32_t mDecodedDataLength;
};
} // namespace net
} // namespace mozilla
#endif

View file

@ -0,0 +1,17 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsISupports.idl"
/**
* nsICompressConvStats
*
* This interface allows for the observation of decoded resource sizes
*/
[builtinclass, scriptable, uuid(58172ad0-46a9-4893-8fde-cd909c10792a)]
interface nsICompressConvStats : nsISupports
{
readonly attribute uint64_t decodedDataLength;
};

View file

@ -0,0 +1,895 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsIndexedToHTML.h"
#include "mozilla/dom/EncodingUtils.h"
#include "nsNetUtil.h"
#include "netCore.h"
#include "nsStringStream.h"
#include "nsIFile.h"
#include "nsIFileURL.h"
#include "nsEscape.h"
#include "nsIDirIndex.h"
#include "nsURLHelper.h"
#include "nsIPlatformCharset.h"
#include "nsIPrefService.h"
#include "nsIPrefBranch.h"
#include "nsIPrefLocalizedString.h"
#include "nsIChromeRegistry.h"
#include "nsIDateTimeFormat.h"
#include "nsIStringBundle.h"
#include "nsITextToSubURI.h"
#include "nsXPIDLString.h"
#include <algorithm>
#include "nsIChannel.h"
NS_IMPL_ISUPPORTS(nsIndexedToHTML,
nsIDirIndexListener,
nsIStreamConverter,
nsIRequestObserver,
nsIStreamListener)
static void AppendNonAsciiToNCR(const nsAString& in, nsCString& out)
{
nsAString::const_iterator start, end;
in.BeginReading(start);
in.EndReading(end);
while (start != end) {
if (*start < 128) {
out.Append(*start++);
} else {
out.AppendLiteral("&#x");
out.AppendInt(*start++, 16);
out.Append(';');
}
}
}
nsresult
nsIndexedToHTML::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult) {
nsresult rv;
if (aOuter)
return NS_ERROR_NO_AGGREGATION;
nsIndexedToHTML* _s = new nsIndexedToHTML();
if (_s == nullptr)
return NS_ERROR_OUT_OF_MEMORY;
rv = _s->QueryInterface(aIID, aResult);
return rv;
}
nsresult
nsIndexedToHTML::Init(nsIStreamListener* aListener) {
nsresult rv = NS_OK;
mListener = aListener;
mDateTime = nsIDateTimeFormat::Create();
if (!mDateTime)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIStringBundleService> sbs =
do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
if (NS_FAILED(rv)) return rv;
rv = sbs->CreateBundle(NECKO_MSGS_URL, getter_AddRefs(mBundle));
mExpectAbsLoc = false;
return rv;
}
NS_IMETHODIMP
nsIndexedToHTML::Convert(nsIInputStream* aFromStream,
const char* aFromType,
const char* aToType,
nsISupports* aCtxt,
nsIInputStream** res) {
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsIndexedToHTML::AsyncConvertData(const char *aFromType,
const char *aToType,
nsIStreamListener *aListener,
nsISupports *aCtxt) {
return Init(aListener);
}
NS_IMETHODIMP
nsIndexedToHTML::OnStartRequest(nsIRequest* request, nsISupports *aContext) {
nsCString buffer;
nsresult rv = DoOnStartRequest(request, aContext, buffer);
if (NS_FAILED(rv)) {
request->Cancel(rv);
}
rv = mListener->OnStartRequest(request, aContext);
if (NS_FAILED(rv)) return rv;
// The request may have been canceled, and if that happens, we want to
// suppress calls to OnDataAvailable.
request->GetStatus(&rv);
if (NS_FAILED(rv)) return rv;
// Push our buffer to the listener.
rv = SendToListener(request, aContext, buffer);
return rv;
}
nsresult
nsIndexedToHTML::DoOnStartRequest(nsIRequest* request, nsISupports *aContext,
nsCString& aBuffer) {
nsresult rv;
nsCOMPtr<nsIChannel> channel = do_QueryInterface(request);
nsCOMPtr<nsIURI> uri;
rv = channel->GetURI(getter_AddRefs(uri));
if (NS_FAILED(rv)) return rv;
channel->SetContentType(NS_LITERAL_CSTRING("text/html"));
mParser = do_CreateInstance("@mozilla.org/dirIndexParser;1",&rv);
if (NS_FAILED(rv)) return rv;
rv = mParser->SetListener(this);
if (NS_FAILED(rv)) return rv;
rv = mParser->OnStartRequest(request, aContext);
if (NS_FAILED(rv)) return rv;
nsAutoCString baseUri, titleUri;
rv = uri->GetAsciiSpec(baseUri);
if (NS_FAILED(rv)) return rv;
titleUri = baseUri;
nsCString parentStr;
nsCString buffer;
buffer.AppendLiteral("<!DOCTYPE html>\n<html>\n<head>\n");
// XXX - should be using the 300: line from the parser.
// We can't guarantee that that comes before any entry, so we'd have to
// buffer, and do other painful stuff.
// I'll deal with this when I make the changes to handle welcome messages
// The .. stuff should also come from the lower level protocols, but that
// would muck up the XUL display
// - bbaetz
bool isScheme = false;
bool isSchemeFile = false;
if (NS_SUCCEEDED(uri->SchemeIs("ftp", &isScheme)) && isScheme) {
// strip out the password here, so it doesn't show in the page title
// This is done by the 300: line generation in ftp, but we don't use
// that - see above
nsAutoCString pw;
rv = uri->GetPassword(pw);
if (NS_FAILED(rv)) return rv;
if (!pw.IsEmpty()) {
nsCOMPtr<nsIURI> newUri;
rv = uri->Clone(getter_AddRefs(newUri));
if (NS_FAILED(rv)) return rv;
rv = newUri->SetPassword(EmptyCString());
if (NS_FAILED(rv)) return rv;
rv = newUri->GetAsciiSpec(titleUri);
if (NS_FAILED(rv)) return rv;
}
nsAutoCString path;
rv = uri->GetPath(path);
if (NS_FAILED(rv)) return rv;
if (!path.EqualsLiteral("//") && !path.LowerCaseEqualsLiteral("/%2f")) {
rv = uri->Resolve(NS_LITERAL_CSTRING(".."),parentStr);
if (NS_FAILED(rv)) return rv;
}
} else if (NS_SUCCEEDED(uri->SchemeIs("file", &isSchemeFile)) && isSchemeFile) {
nsCOMPtr<nsIFileURL> fileUrl = do_QueryInterface(uri);
nsCOMPtr<nsIFile> file;
rv = fileUrl->GetFile(getter_AddRefs(file));
if (NS_FAILED(rv)) return rv;
file->SetFollowLinks(true);
nsAutoCString url;
rv = net_GetURLSpecFromFile(file, url);
if (NS_FAILED(rv)) return rv;
baseUri.Assign(url);
nsCOMPtr<nsIFile> parent;
rv = file->GetParent(getter_AddRefs(parent));
if (parent && NS_SUCCEEDED(rv)) {
net_GetURLSpecFromDir(parent, url);
if (NS_FAILED(rv)) return rv;
parentStr.Assign(url);
}
// Directory index will be always encoded in UTF-8 if this is file url
buffer.AppendLiteral("<meta charset=\"UTF-8\">\n");
} else if (NS_SUCCEEDED(uri->SchemeIs("jar", &isScheme)) && isScheme) {
nsAutoCString path;
rv = uri->GetPath(path);
if (NS_FAILED(rv)) return rv;
// a top-level jar directory URL is of the form jar:foo.zip!/
// path will be of the form foo.zip!/, and its last two characters
// will be "!/"
//XXX this won't work correctly when the name of the directory being
//XXX displayed ends with "!", but then again, jar: URIs don't deal
//XXX particularly well with such directories anyway
if (!StringEndsWith(path, NS_LITERAL_CSTRING("!/"))) {
rv = uri->Resolve(NS_LITERAL_CSTRING(".."), parentStr);
if (NS_FAILED(rv)) return rv;
}
}
else {
// default behavior for other protocols is to assume the channel's
// URL references a directory ending in '/' -- fixup if necessary.
nsAutoCString path;
rv = uri->GetPath(path);
if (NS_FAILED(rv)) return rv;
if (baseUri.Last() != '/') {
baseUri.Append('/');
path.Append('/');
uri->SetPath(path);
}
if (!path.EqualsLiteral("/")) {
rv = uri->Resolve(NS_LITERAL_CSTRING(".."), parentStr);
if (NS_FAILED(rv)) return rv;
}
}
buffer.AppendLiteral("<style type=\"text/css\">\n"
":root {\n"
" font-family: sans-serif;\n"
"}\n"
"img {\n"
" border: 0;\n"
"}\n"
"th {\n"
" text-align: start;\n"
" white-space: nowrap;\n"
"}\n"
"th > a {\n"
" color: inherit;\n"
"}\n"
"table[order] > thead > tr > th {\n"
" cursor: pointer;\n"
"}\n"
"table[order] > thead > tr > th::after {\n"
" display: none;\n"
" width: .8em;\n"
" margin-inline-end: -.8em;\n"
" text-align: end;\n"
"}\n"
"table[order=\"asc\"] > thead > tr > th::after {\n"
" content: \"\\2193\"; /* DOWNWARDS ARROW (U+2193) */\n"
"}\n"
"table[order=\"desc\"] > thead > tr > th::after {\n"
" content: \"\\2191\"; /* UPWARDS ARROW (U+2191) */\n"
"}\n"
"table[order][order-by=\"0\"] > thead > tr > th:first-child > a ,\n"
"table[order][order-by=\"1\"] > thead > tr > th:first-child + th > a ,\n"
"table[order][order-by=\"2\"] > thead > tr > th:first-child + th + th > a {\n"
" text-decoration: underline;\n"
"}\n"
"table[order][order-by=\"0\"] > thead > tr > th:first-child::after ,\n"
"table[order][order-by=\"1\"] > thead > tr > th:first-child + th::after ,\n"
"table[order][order-by=\"2\"] > thead > tr > th:first-child + th + th::after {\n"
" display: inline-block;\n"
"}\n"
"table.remove-hidden > tbody > tr.hidden-object {\n"
" display: none;\n"
"}\n"
"td {\n"
" white-space: nowrap;\n"
"}\n"
"table.ellipsis {\n"
" width: 100%;\n"
" table-layout: fixed;\n"
" border-spacing: 0;\n"
"}\n"
"table.ellipsis > tbody > tr > td {\n"
" padding: 0;\n"
" overflow: hidden;\n"
" text-overflow: ellipsis;\n"
"}\n"
"/* name */\n"
"/* name */\n"
"th:first-child {\n"
" padding-inline-end: 2em;\n"
"}\n"
"/* size */\n"
"th:first-child + th {\n"
" padding-inline-end: 1em;\n"
"}\n"
"td:first-child + td {\n"
" text-align: end;\n"
" padding-inline-end: 1em;\n"
"}\n"
"/* date */\n"
"td:first-child + td + td {\n"
" padding-inline-start: 1em;\n"
" padding-inline-end: .5em;\n"
"}\n"
"/* time */\n"
"td:first-child + td + td + td {\n"
" padding-inline-start: .5em;\n"
"}\n"
".symlink {\n"
" font-style: italic;\n"
"}\n"
".dir ,\n"
".symlink ,\n"
".file {\n"
" margin-inline-start: 20px;\n"
"}\n"
".dir::before ,\n"
".file > img {\n"
" margin-inline-end: 4px;\n"
" margin-inline-start: -20px;\n"
" max-width: 16px;\n"
" max-height: 16px;\n"
" vertical-align: middle;\n"
"}\n"
".dir::before {\n"
" content: url(resource://gre/res/html/folder.png);\n"
"}\n"
"</style>\n"
"<link rel=\"stylesheet\" media=\"screen, projection\" type=\"text/css\""
" href=\"chrome://global/skin/dirListing/dirListing.css\">\n"
"<script type=\"application/javascript\">\n"
"'use strict';\n"
"var gTable, gOrderBy, gTBody, gRows, gUI_showHidden;\n"
"document.addEventListener(\"DOMContentLoaded\", function() {\n"
" gTable = document.getElementsByTagName(\"table\")[0];\n"
" gTBody = gTable.tBodies[0];\n"
" if (gTBody.rows.length < 2)\n"
" return;\n"
" gUI_showHidden = document.getElementById(\"UI_showHidden\");\n"
" var headCells = gTable.tHead.rows[0].cells,\n"
" hiddenObjects = false;\n"
" function rowAction(i) {\n"
" return function(event) {\n"
" event.preventDefault();\n"
" orderBy(i);\n"
" }\n"
" }\n"
" for (var i = headCells.length - 1; i >= 0; i--) {\n"
" var anchor = document.createElement(\"a\");\n"
" anchor.href = \"\";\n"
" anchor.appendChild(headCells[i].firstChild);\n"
" headCells[i].appendChild(anchor);\n"
" headCells[i].addEventListener(\"click\", rowAction(i), true);\n"
" }\n"
" if (gUI_showHidden) {\n"
" gRows = Array.slice(gTBody.rows);\n"
" hiddenObjects = gRows.some(row => row.className == \"hidden-object\");\n"
" }\n"
" gTable.setAttribute(\"order\", \"\");\n"
" if (hiddenObjects) {\n"
" gUI_showHidden.style.display = \"block\";\n"
" updateHidden();\n"
" }\n"
"}, \"false\");\n"
"function compareRows(rowA, rowB) {\n"
" var a = rowA.cells[gOrderBy].getAttribute(\"sortable-data\") || \"\";\n"
" var b = rowB.cells[gOrderBy].getAttribute(\"sortable-data\") || \"\";\n"
" var intA = +a;\n"
" var intB = +b;\n"
" if (a == intA && b == intB) {\n"
" a = intA;\n"
" b = intB;\n"
" } else {\n"
" a = a.toLowerCase();\n"
" b = b.toLowerCase();\n"
" }\n"
" if (a < b)\n"
" return -1;\n"
" if (a > b)\n"
" return 1;\n"
" return 0;\n"
"}\n"
"function orderBy(column) {\n"
" if (!gRows)\n"
" gRows = Array.slice(gTBody.rows);\n"
" var order;\n"
" if (gOrderBy == column) {\n"
" order = gTable.getAttribute(\"order\") == \"asc\" ? \"desc\" : \"asc\";\n"
" } else {\n"
" order = \"asc\";\n"
" gOrderBy = column;\n"
" gTable.setAttribute(\"order-by\", column);\n"
" gRows.sort(compareRows);\n"
" }\n"
" gTable.removeChild(gTBody);\n"
" gTable.setAttribute(\"order\", order);\n"
" if (order == \"asc\")\n"
" for (var i = 0; i < gRows.length; i++)\n"
" gTBody.appendChild(gRows[i]);\n"
" else\n"
" for (var i = gRows.length - 1; i >= 0; i--)\n"
" gTBody.appendChild(gRows[i]);\n"
" gTable.appendChild(gTBody);\n"
"}\n"
"function updateHidden() {\n"
" gTable.className = gUI_showHidden.getElementsByTagName(\"input\")[0].checked ?\n"
" \"\" :\n"
" \"remove-hidden\";\n"
"}\n"
"</script>\n");
buffer.AppendLiteral("<link rel=\"icon\" type=\"image/png\" href=\"");
nsCOMPtr<nsIURI> innerUri = NS_GetInnermostURI(uri);
if (!innerUri)
return NS_ERROR_UNEXPECTED;
nsCOMPtr<nsIFileURL> fileURL(do_QueryInterface(innerUri));
//XXX bug 388553: can't use skinnable icons here due to security restrictions
if (fileURL) {
//buffer.AppendLiteral("chrome://global/skin/dirListing/local.png");
buffer.AppendLiteral("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB"
"AAAAAQCAYAAAAf8%2F9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9i"
"ZSBJbWFnZVJlYWR5ccllPAAAAjFJREFUeNqsU8uOElEQPffR"
"3XQ3ONASdBJCSBxHos5%2B3Bg3rvkCv8PElS78gPkO%2FATj"
"QoUdO2ftrJiRh6aneTb9sOpC4weMN6lcuFV16pxDIfI8x12O"
"YIDhcPiu2Wx%2B%2FHF5CW1Z6Jyegt%2FTNEWSJIjjGFEUIQ"
"xDrFYrWFSzXC4%2FdLvd95pRKpXKy%2BpRFZ7nwaWo1%2BsG"
"nQG2260BKJfLKJVKGI1GEEJw7ateryd0v993W63WEwjgxfn5"
"obGYzgCbzcaEbdsIggDj8Riu6z6iUk9SYZMSx8W0LMsM%2FS"
"KK75xnJlIq80anQXdbEp0OhcPJ0eiaJnGRMEyyPDsAKKUM9c"
"lkYoDo3SZJzzSdp0VSKYmfV1co%2Bz580kw5KDIM8RbRfEnU"
"f1HzxtQyMAGcaGruTKczMzEIaqhKifV6jd%2BzGQQB5llunF"
"%2FM52BizC2K5sYPYvZcu653tjOM9O93wnYc08gmkgg4VAxi"
"xfqFUJT36AYBZGd6PJkFCZnnlBxMp38gqIgLpZB0y4Nph18l"
"yWh5FFbrOSxbl3V4G%2BVB7T4ajYYxTyuLtO%2BCvWGgJE1M"
"c7JNsJEhvgw%2FQV4fo%2F24nbEsX2u1d5sVyn8sJO0ZAQiI"
"YnFh%2BxrfLz%2Fj29cBS%2FO14zg3i8XigW3ZkErDtmKoeM"
"%2BAJGRMnXeEPGKf0nCD1ydvkDzU9Jbc6OpR7WIw6L8lQ%2B"
"4pQ1%2FlPF0RGM9Ns91Wmptk0GfB4EJkt77vXYj%2F8m%2B8"
"y%2FkrwABHbz2H9V68DQAAAABJRU5ErkJggg%3D%3D");
} else {
//buffer.AppendLiteral("chrome://global/skin/dirListing/remote.png");
buffer.AppendLiteral("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB"
"AAAAAQCAYAAAAf8%2F9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9i"
"ZSBJbWFnZVJlYWR5ccllPAAAAeBJREFUeNqcU81O20AQ%2Ft"
"Z2AgQSYQRqL1UPVG2hAUQkxLEStz4DrXpLpD5Drz31Cajax%"
"2Bghhx6qHIJURBTxIwQRwopCBbZjHMcOTrzermPipsSt1Iw0"
"3p3ZmW%2B%2B2R0TxhgOD34wjCHZlQ0iDYz9yvEfhxMTCYhE"
"QDIZhkxKd2sqzX2TOD2vBQCQhpPefng1ZP2dVPlLLdpL8SEM"
"cxng%2Fbs0RIHhtgs4twxOh%2BHjZxvzDx%2F3GQQiDFISiR"
"BLFMPKTRMollzcWECrDVhtxtdRVsL9youPxGj%2FbdfFlUZh"
"tDyYbYqWRUdai1oQRZ5oHeHl2gNM%2B01Uqio8RlH%2Bnsaz"
"JzNwXcq1B%2BiXPHprlEEymeBfXs1w8XxxihfyuXqoHqpoGj"
"ZM04bddgG%2F9%2B8WGj87qDdsrK9m%2BoA%2BpbhQTDh2l1"
"%2Bi2weNbSHMZyjvNXmVbqh9Fj5Oz27uEoP%2BSTxANruJs9"
"L%2FT6P0ewqPx5nmiAG5f6AoCtN1PbJzuRyJAyDBzzSQYvEr"
"f06yYxhGXlEa8H2KVGoasjwLx3Ewk858opQWXm%2B%2Fib9E"
"QrBzclLLLy89xYvlpchvtixcX6uo1y%2FzsiwHrkIsgKbp%2"
"BYWFOWicuqppoNTnStHzPFCPQhBEBOyGAX4JMADFetubi4BS"
"YAAAAABJRU5ErkJggg%3D%3D");
}
buffer.AppendLiteral("\">\n<title>");
// Everything needs to end in a /,
// otherwise we end up linking to file:///foo/dirfile
if (!mTextToSubURI) {
mTextToSubURI = do_GetService(NS_ITEXTTOSUBURI_CONTRACTID, &rv);
if (NS_FAILED(rv)) return rv;
}
nsXPIDLCString encoding;
rv = uri->GetOriginCharset(encoding);
if (NS_FAILED(rv)) return rv;
if (encoding.IsEmpty()) {
encoding.AssignLiteral("UTF-8");
}
nsXPIDLString unEscapeSpec;
rv = mTextToSubURI->UnEscapeAndConvert(encoding, titleUri.get(),
getter_Copies(unEscapeSpec));
// unescape may fail because
// 1. file URL may be encoded in platform charset for backward compatibility
// 2. query part may not be encoded in UTF-8 (see bug 261929)
// so try the platform's default if this is file url
if (NS_FAILED(rv) && isSchemeFile) {
nsCOMPtr<nsIPlatformCharset> platformCharset(do_GetService(NS_PLATFORMCHARSET_CONTRACTID, &rv));
NS_ENSURE_SUCCESS(rv, rv);
nsAutoCString charset;
rv = platformCharset->GetCharset(kPlatformCharsetSel_FileName, charset);
NS_ENSURE_SUCCESS(rv, rv);
rv = mTextToSubURI->UnEscapeAndConvert(charset.get(), titleUri.get(),
getter_Copies(unEscapeSpec));
}
if (NS_FAILED(rv)) return rv;
nsXPIDLString htmlEscSpec;
htmlEscSpec.Adopt(nsEscapeHTML2(unEscapeSpec.get(),
unEscapeSpec.Length()));
nsXPIDLString title;
const char16_t* formatTitle[] = {
htmlEscSpec.get()
};
rv = mBundle->FormatStringFromName(u"DirTitle",
formatTitle,
sizeof(formatTitle)/sizeof(char16_t*),
getter_Copies(title));
if (NS_FAILED(rv)) return rv;
// we want to convert string bundle to NCR
// to ensure they're shown in any charsets
AppendNonAsciiToNCR(title, buffer);
buffer.AppendLiteral("</title>\n");
// If there is a quote character in the baseUri, then
// lets not add a base URL. The reason for this is that
// if we stick baseUri containing a quote into a quoted
// string, the quote character will prematurely close
// the base href string. This is a fall-back check;
// that's why it is OK to not use a base rather than
// trying to play nice and escaping the quotes. See bug
// 358128.
if (!baseUri.Contains('"'))
{
// Great, the baseUri does not contain a char that
// will prematurely close the string. Go ahead an
// add a base href, but only do so if we're not
// dealing with a resource URI.
nsCOMPtr<nsIURI> originalUri;
rv = channel->GetOriginalURI(getter_AddRefs(originalUri));
bool wasResource = false;
if (NS_FAILED(rv) ||
NS_FAILED(originalUri->SchemeIs("resource", &wasResource)) ||
!wasResource) {
buffer.AppendLiteral("<base href=\"");
nsAdoptingCString htmlEscapedUri(nsEscapeHTML(baseUri.get()));
buffer.Append(htmlEscapedUri);
buffer.AppendLiteral("\" />\n");
}
}
else
{
NS_ERROR("broken protocol handler didn't escape double-quote.");
}
nsCString direction(NS_LITERAL_CSTRING("ltr"));
nsCOMPtr<nsIXULChromeRegistry> reg =
mozilla::services::GetXULChromeRegistryService();
if (reg) {
bool isRTL = false;
reg->IsLocaleRTL(NS_LITERAL_CSTRING("global"), &isRTL);
if (isRTL) {
direction.AssignLiteral("rtl");
}
}
buffer.AppendLiteral("</head>\n<body dir=\"");
buffer.Append(direction);
buffer.AppendLiteral("\">\n<h1>");
const char16_t* formatHeading[] = {
htmlEscSpec.get()
};
rv = mBundle->FormatStringFromName(u"DirTitle",
formatHeading,
sizeof(formatHeading)/sizeof(char16_t*),
getter_Copies(title));
if (NS_FAILED(rv)) return rv;
AppendNonAsciiToNCR(title, buffer);
buffer.AppendLiteral("</h1>\n");
if (!parentStr.IsEmpty()) {
nsXPIDLString parentText;
rv = mBundle->GetStringFromName(u"DirGoUp",
getter_Copies(parentText));
if (NS_FAILED(rv)) return rv;
buffer.AppendLiteral("<p id=\"UI_goUp\"><a class=\"up\" href=\"");
nsAdoptingCString htmlParentStr(nsEscapeHTML(parentStr.get()));
buffer.Append(htmlParentStr);
buffer.AppendLiteral("\">");
AppendNonAsciiToNCR(parentText, buffer);
buffer.AppendLiteral("</a></p>\n");
}
if (isSchemeFile) {
nsXPIDLString showHiddenText;
rv = mBundle->GetStringFromName(u"ShowHidden",
getter_Copies(showHiddenText));
if (NS_FAILED(rv)) return rv;
buffer.AppendLiteral("<p id=\"UI_showHidden\" style=\"display:none\"><label><input type=\"checkbox\" checked onchange=\"updateHidden()\">");
AppendNonAsciiToNCR(showHiddenText, buffer);
buffer.AppendLiteral("</label></p>\n");
}
buffer.AppendLiteral("<table>\n");
nsXPIDLString columnText;
buffer.AppendLiteral(" <thead>\n"
" <tr>\n"
" <th>");
rv = mBundle->GetStringFromName(u"DirColName",
getter_Copies(columnText));
if (NS_FAILED(rv)) return rv;
AppendNonAsciiToNCR(columnText, buffer);
buffer.AppendLiteral("</th>\n"
" <th>");
rv = mBundle->GetStringFromName(u"DirColSize",
getter_Copies(columnText));
if (NS_FAILED(rv)) return rv;
AppendNonAsciiToNCR(columnText, buffer);
buffer.AppendLiteral("</th>\n"
" <th colspan=\"2\">");
rv = mBundle->GetStringFromName(u"DirColMTime",
getter_Copies(columnText));
if (NS_FAILED(rv)) return rv;
AppendNonAsciiToNCR(columnText, buffer);
buffer.AppendLiteral("</th>\n"
" </tr>\n"
" </thead>\n");
buffer.AppendLiteral(" <tbody>\n");
aBuffer = buffer;
return rv;
}
NS_IMETHODIMP
nsIndexedToHTML::OnStopRequest(nsIRequest* request, nsISupports *aContext,
nsresult aStatus) {
if (NS_SUCCEEDED(aStatus)) {
nsCString buffer;
buffer.AssignLiteral("</tbody></table></body></html>\n");
aStatus = SendToListener(request, aContext, buffer);
}
mParser->OnStopRequest(request, aContext, aStatus);
mParser = nullptr;
return mListener->OnStopRequest(request, aContext, aStatus);
}
nsresult
nsIndexedToHTML::SendToListener(nsIRequest* aRequest, nsISupports *aContext, const nsACString &aBuffer)
{
nsCOMPtr<nsIInputStream> inputData;
nsresult rv = NS_NewCStringInputStream(getter_AddRefs(inputData), aBuffer);
NS_ENSURE_SUCCESS(rv, rv);
return mListener->OnDataAvailable(aRequest, aContext,
inputData, 0, aBuffer.Length());
}
NS_IMETHODIMP
nsIndexedToHTML::OnDataAvailable(nsIRequest *aRequest,
nsISupports *aCtxt,
nsIInputStream* aInput,
uint64_t aOffset,
uint32_t aCount) {
return mParser->OnDataAvailable(aRequest, aCtxt, aInput, aOffset, aCount);
}
NS_IMETHODIMP
nsIndexedToHTML::OnIndexAvailable(nsIRequest *aRequest,
nsISupports *aCtxt,
nsIDirIndex *aIndex) {
nsresult rv;
if (!aIndex)
return NS_ERROR_NULL_POINTER;
nsCString pushBuffer;
pushBuffer.AppendLiteral("<tr");
// We don't know the file's character set yet, so retrieve the raw bytes
// which will be decoded by the HTML parser.
nsXPIDLCString loc;
aIndex->GetLocation(getter_Copies(loc));
// Adjust the length in case unescaping shortened the string.
loc.Truncate(nsUnescapeCount(loc.BeginWriting()));
if (loc.IsEmpty()) {
return NS_ERROR_ILLEGAL_VALUE;
}
if (loc.First() == char16_t('.'))
pushBuffer.AppendLiteral(" class=\"hidden-object\"");
pushBuffer.AppendLiteral(">\n <td sortable-data=\"");
// The sort key is the name of the item, prepended by either 0, 1 or 2
// in order to group items.
uint32_t type;
aIndex->GetType(&type);
switch (type) {
case nsIDirIndex::TYPE_SYMLINK:
pushBuffer.Append('0');
break;
case nsIDirIndex::TYPE_DIRECTORY:
pushBuffer.Append('1');
break;
default:
pushBuffer.Append('2');
break;
}
nsAdoptingCString escaped(nsEscapeHTML(loc));
pushBuffer.Append(escaped);
pushBuffer.AppendLiteral("\"><table class=\"ellipsis\"><tbody><tr><td><a class=\"");
switch (type) {
case nsIDirIndex::TYPE_DIRECTORY:
pushBuffer.AppendLiteral("dir");
break;
case nsIDirIndex::TYPE_SYMLINK:
pushBuffer.AppendLiteral("symlink");
break;
default:
pushBuffer.AppendLiteral("file");
break;
}
pushBuffer.AppendLiteral("\" href=\"");
// need to escape links
nsAutoCString locEscaped;
// Adding trailing slash helps to recognize whether the URL points to a file
// or a directory (bug #214405).
if ((type == nsIDirIndex::TYPE_DIRECTORY) && (loc.Last() != '/')) {
loc.Append('/');
}
// now minimally re-escape the location...
uint32_t escFlags;
// for some protocols, we expect the location to be absolute.
// if so, and if the location indeed appears to be a valid URI, then go
// ahead and treat it like one.
nsAutoCString scheme;
if (mExpectAbsLoc &&
NS_SUCCEEDED(net_ExtractURLScheme(loc, scheme))) {
// escape as absolute
escFlags = esc_Forced | esc_AlwaysCopy | esc_Minimal;
}
else {
// escape as relative
// esc_Directory is needed because directories have a trailing slash.
// Without it, the trailing '/' will be escaped, and links from within
// that directory will be incorrect
escFlags = esc_Forced | esc_AlwaysCopy | esc_FileBaseName | esc_Colon | esc_Directory;
}
NS_EscapeURL(loc.get(), loc.Length(), escFlags, locEscaped);
// esc_Directory does not escape the semicolons, so if a filename
// contains semicolons we need to manually escape them.
// This replacement should be removed in bug #473280
locEscaped.ReplaceSubstring(";", "%3b");
nsAdoptingCString htmlEscapedURL(nsEscapeHTML(locEscaped.get()));
pushBuffer.Append(htmlEscapedURL);
pushBuffer.AppendLiteral("\">");
if (type == nsIDirIndex::TYPE_FILE || type == nsIDirIndex::TYPE_UNKNOWN) {
pushBuffer.AppendLiteral("<img src=\"moz-icon://");
int32_t lastDot = locEscaped.RFindChar('.');
if (lastDot != kNotFound) {
locEscaped.Cut(0, lastDot);
nsAdoptingCString htmlFileExt(nsEscapeHTML(locEscaped.get()));
pushBuffer.Append(htmlFileExt);
} else {
pushBuffer.AppendLiteral("unknown");
}
pushBuffer.AppendLiteral("?size=16\" alt=\"");
nsXPIDLString altText;
rv = mBundle->GetStringFromName(u"DirFileLabel",
getter_Copies(altText));
if (NS_FAILED(rv)) return rv;
AppendNonAsciiToNCR(altText, pushBuffer);
pushBuffer.AppendLiteral("\">");
}
pushBuffer.Append(escaped);
pushBuffer.AppendLiteral("</a></td></tr></tbody></table></td>\n <td");
if (type == nsIDirIndex::TYPE_DIRECTORY || type == nsIDirIndex::TYPE_SYMLINK) {
pushBuffer.Append('>');
} else {
int64_t size;
aIndex->GetSize(&size);
if (uint64_t(size) != UINT64_MAX) {
pushBuffer.AppendLiteral(" sortable-data=\"");
pushBuffer.AppendInt(size);
pushBuffer.AppendLiteral("\">");
nsAutoCString sizeString;
FormatSizeString(size, sizeString);
pushBuffer.Append(sizeString);
} else {
pushBuffer.Append('>');
}
}
pushBuffer.AppendLiteral("</td>\n <td");
PRTime t;
aIndex->GetLastModified(&t);
if (t == -1LL) {
pushBuffer.AppendLiteral("></td>\n <td>");
} else {
pushBuffer.AppendLiteral(" sortable-data=\"");
pushBuffer.AppendInt(static_cast<int64_t>(t));
pushBuffer.AppendLiteral("\">");
nsAutoString formatted;
mDateTime->FormatPRTime(nullptr,
kDateFormatShort,
kTimeFormatNone,
t,
formatted);
AppendNonAsciiToNCR(formatted, pushBuffer);
pushBuffer.AppendLiteral("</td>\n <td>");
mDateTime->FormatPRTime(nullptr,
kDateFormatNone,
kTimeFormatSeconds,
t,
formatted);
// use NCR to show date in any doc charset
AppendNonAsciiToNCR(formatted, pushBuffer);
}
pushBuffer.AppendLiteral("</td>\n</tr>");
return SendToListener(aRequest, aCtxt, pushBuffer);
}
NS_IMETHODIMP
nsIndexedToHTML::OnInformationAvailable(nsIRequest *aRequest,
nsISupports *aCtxt,
const nsAString& aInfo) {
nsAutoCString pushBuffer;
nsAdoptingString escaped(nsEscapeHTML2(PromiseFlatString(aInfo).get()));
if (!escaped)
return NS_ERROR_OUT_OF_MEMORY;
pushBuffer.AppendLiteral("<tr>\n <td>");
// escaped is provided in Unicode, so write hex NCRs as necessary
// to prevent the HTML parser from applying a character set.
AppendNonAsciiToNCR(escaped, pushBuffer);
pushBuffer.AppendLiteral("</td>\n <td></td>\n <td></td>\n <td></td>\n</tr>\n");
return SendToListener(aRequest, aCtxt, pushBuffer);
}
void nsIndexedToHTML::FormatSizeString(int64_t inSize, nsCString& outSizeString)
{
outSizeString.Truncate();
if (inSize > int64_t(0)) {
// round up to the nearest Kilobyte
int64_t upperSize = (inSize + int64_t(1023)) / int64_t(1024);
outSizeString.AppendInt(upperSize);
outSizeString.AppendLiteral(" KB");
}
}
nsIndexedToHTML::nsIndexedToHTML() {
}
nsIndexedToHTML::~nsIndexedToHTML() {
}

View file

@ -0,0 +1,63 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef ____nsindexedtohtml___h___
#define ____nsindexedtohtml___h___
#include "nsCOMPtr.h"
#include "nsString.h"
#include "nsIStreamConverter.h"
#include "nsIDirIndexListener.h"
#define NS_NSINDEXEDTOHTMLCONVERTER_CID \
{ 0xcf0f71fd, 0xfafd, 0x4e2b, {0x9f, 0xdc, 0x13, 0x4d, 0x97, 0x2e, 0x16, 0xe2} }
class nsIDateTimeFormat;
class nsIStringBundle;
class nsITextToSubURI;
class nsIndexedToHTML : public nsIStreamConverter,
public nsIDirIndexListener
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSISTREAMCONVERTER
NS_DECL_NSIREQUESTOBSERVER
NS_DECL_NSISTREAMLISTENER
NS_DECL_NSIDIRINDEXLISTENER
nsIndexedToHTML();
nsresult Init(nsIStreamListener *aListener);
static nsresult
Create(nsISupports *aOuter, REFNSIID aIID, void **aResult);
protected:
void FormatSizeString(int64_t inSize, nsCString& outSizeString);
nsresult SendToListener(nsIRequest* aRequest, nsISupports *aContext, const nsACString &aBuffer);
// Helper to properly implement OnStartRequest
nsresult DoOnStartRequest(nsIRequest* request, nsISupports *aContext,
nsCString& aBuffer);
protected:
nsCOMPtr<nsIDirIndexParser> mParser;
nsCOMPtr<nsIStreamListener> mListener; // final listener (consumer)
nsCOMPtr<nsIDateTimeFormat> mDateTime;
nsCOMPtr<nsIStringBundle> mBundle;
nsCOMPtr<nsITextToSubURI> mTextToSubURI;
private:
// Expecting absolute locations, given by 201 lines.
bool mExpectAbsLoc;
virtual ~nsIndexedToHTML();
};
#endif

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,176 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef __nsmultimixedconv__h__
#define __nsmultimixedconv__h__
#include "nsIStreamConverter.h"
#include "nsIChannel.h"
#include "nsString.h"
#include "nsCOMPtr.h"
#include "nsIByteRangeRequest.h"
#include "nsILoadInfo.h"
#include "nsIMultiPartChannel.h"
#include "nsAutoPtr.h"
#include "mozilla/Attributes.h"
#include "nsHttpResponseHead.h"
#define NS_MULTIMIXEDCONVERTER_CID \
{ /* 7584CE90-5B25-11d3-A175-0050041CAF44 */ \
0x7584ce90, \
0x5b25, \
0x11d3, \
{0xa1, 0x75, 0x0, 0x50, 0x4, 0x1c, 0xaf, 0x44} \
}
//
// nsPartChannel is a "dummy" channel which represents an individual part of
// a multipart/mixed stream...
//
// Instances on this channel are passed out to the consumer through the
// nsIStreamListener interface.
//
class nsPartChannel final : public nsIChannel,
public nsIByteRangeRequest,
public nsIMultiPartChannel
{
public:
nsPartChannel(nsIChannel *aMultipartChannel, uint32_t aPartID,
nsIStreamListener* aListener);
void InitializeByteRange(int64_t aStart, int64_t aEnd);
void SetIsLastPart() { mIsLastPart = true; }
nsresult SendOnStartRequest(nsISupports* aContext);
nsresult SendOnDataAvailable(nsISupports* aContext, nsIInputStream* aStream,
uint64_t aOffset, uint32_t aLen);
nsresult SendOnStopRequest(nsISupports* aContext, nsresult aStatus);
/* SetContentDisposition expects the full value of the Content-Disposition
* header */
void SetContentDisposition(const nsACString& aContentDispositionHeader);
void SetResponseHead(mozilla::net::nsHttpResponseHead * head) { mResponseHead = head; }
NS_DECL_ISUPPORTS
NS_DECL_NSIREQUEST
NS_DECL_NSICHANNEL
NS_DECL_NSIBYTERANGEREQUEST
NS_DECL_NSIMULTIPARTCHANNEL
protected:
~nsPartChannel();
protected:
nsCOMPtr<nsIChannel> mMultipartChannel;
nsCOMPtr<nsIStreamListener> mListener;
nsAutoPtr<mozilla::net::nsHttpResponseHead> mResponseHead;
nsresult mStatus;
nsLoadFlags mLoadFlags;
nsCOMPtr<nsILoadGroup> mLoadGroup;
nsCString mContentType;
nsCString mContentCharset;
uint32_t mContentDisposition;
nsString mContentDispositionFilename;
nsCString mContentDispositionHeader;
uint64_t mContentLength;
bool mIsByteRangeRequest;
int64_t mByteRangeStart;
int64_t mByteRangeEnd;
uint32_t mPartID; // unique ID that can be used to identify
// this part of the multipart document
bool mIsLastPart;
};
// The nsMultiMixedConv stream converter converts a stream of type "multipart/x-mixed-replace"
// to it's subparts. There was some debate as to whether or not the functionality desired
// when HTTP confronted this type required a stream converter. After all, this type really
// prompts various viewer related actions rather than stream conversion. There simply needs
// to be a piece in place that can strip out the multiple parts of a stream of this type, and
// "display" them accordingly.
//
// With that said, this "stream converter" spends more time packaging up the sub parts of the
// main stream and sending them off the destination stream listener, than doing any real
// stream parsing/converting.
//
// WARNING: This converter requires that it's destination stream listener be able to handle
// multiple OnStartRequest(), OnDataAvailable(), and OnStopRequest() call combinations.
// Each series represents the beginning, data production, and ending phase of each sub-
// part of the original stream.
//
// NOTE: this MIME-type is used by HTTP, *not* SMTP, or IMAP.
//
// NOTE: For reference, a general description of how this MIME type should be handled via
// HTTP, see http://home.netscape.com/assist/net_sites/pushpull.html . Note that
// real world server content deviates considerably from this overview.
//
// Implementation assumptions:
// Assumed structue:
// --BoundaryToken[\r]\n
// content-type: foo/bar[\r]\n
// ... (other headers if any)
// [\r]\n (second line feed to delimit end of headers)
// data
// --BoundaryToken-- (end delimited by final "--")
//
// linebreaks can be either CRLF or LFLF. linebreaks preceding
// boundary tokens are considered part of the data. BoundaryToken
// is any opaque string.
//
//
class nsMultiMixedConv : public nsIStreamConverter {
public:
NS_DECL_ISUPPORTS
NS_DECL_NSISTREAMCONVERTER
NS_DECL_NSISTREAMLISTENER
NS_DECL_NSIREQUESTOBSERVER
nsMultiMixedConv();
protected:
virtual ~nsMultiMixedConv();
nsresult SendStart(nsIChannel *aChannel);
nsresult SendStop(nsresult aStatus);
nsresult SendData(char *aBuffer, uint32_t aLen);
nsresult ParseHeaders(nsIChannel *aChannel, char *&aPtr,
uint32_t &aLen, bool *_retval);
int32_t PushOverLine(char *&aPtr, uint32_t &aLen);
char *FindToken(char *aCursor, uint32_t aLen);
nsresult BufferData(char *aData, uint32_t aLen);
// member data
bool mNewPart; // Are we processing the beginning of a part?
bool mProcessingHeaders;
nsCOMPtr<nsIStreamListener> mFinalListener; // this guy gets the converted data via his OnDataAvailable()
nsCString mToken;
uint32_t mTokenLen;
RefPtr<nsPartChannel> mPartChannel; // the channel for the given part we're processing.
// one channel per part.
nsCOMPtr<nsISupports> mContext;
nsCString mContentType;
nsCString mContentDisposition;
uint64_t mContentLength;
char *mBuffer;
uint32_t mBufLen;
uint64_t mTotalSent;
bool mFirstOnData; // used to determine if we're in our first OnData callback.
// The following members are for tracking the byte ranges in
// multipart/mixed content which specified the 'Content-Range:'
// header...
int64_t mByteRangeStart;
int64_t mByteRangeEnd;
bool mIsByteRangeRequest;
uint32_t mCurrentPartID;
};
#endif /* __nsmultimixedconv__h__ */

View file

@ -0,0 +1,314 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsTXTToHTMLConv.h"
#include "nsEscape.h"
#include "nsStringStream.h"
#include "nsAutoPtr.h"
#include "nsIChannel.h"
#include <algorithm>
#include "mozilla/UniquePtrExtensions.h"
#define TOKEN_DELIMITERS u"\t\r\n "
using namespace mozilla;
// nsISupports methods
NS_IMPL_ISUPPORTS(nsTXTToHTMLConv,
nsIStreamConverter,
nsITXTToHTMLConv,
nsIRequestObserver,
nsIStreamListener)
// nsIStreamConverter methods
NS_IMETHODIMP
nsTXTToHTMLConv::Convert(nsIInputStream *aFromStream,
const char *aFromType, const char *aToType,
nsISupports *aCtxt, nsIInputStream * *_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsTXTToHTMLConv::AsyncConvertData(const char *aFromType,
const char *aToType,
nsIStreamListener *aListener,
nsISupports *aCtxt)
{
NS_ASSERTION(aListener, "null pointer");
mListener = aListener;
return NS_OK;
}
// nsIRequestObserver methods
NS_IMETHODIMP
nsTXTToHTMLConv::OnStartRequest(nsIRequest* request, nsISupports *aContext)
{
mBuffer.AssignLiteral("<html>\n<head><title>");
mBuffer.Append(mPageTitle);
mBuffer.AppendLiteral("</title></head>\n<body>\n");
if (mPreFormatHTML) { // Use <pre> tags
mBuffer.AppendLiteral("<pre>\n");
}
// Push mBuffer to the listener now, so the initial HTML will not
// be parsed in OnDataAvailable().
nsCOMPtr<nsIChannel> channel = do_QueryInterface(request);
if (channel)
channel->SetContentType(NS_LITERAL_CSTRING("text/html"));
// else, assume there is a channel somewhere that knows what it is doing!
nsresult rv = mListener->OnStartRequest(request, aContext);
if (NS_FAILED(rv)) return rv;
// The request may have been canceled, and if that happens, we want to
// suppress calls to OnDataAvailable.
request->GetStatus(&rv);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIInputStream> inputData;
NS_LossyConvertUTF16toASCII asciiData(mBuffer);
rv = NS_NewCStringInputStream(getter_AddRefs(inputData), asciiData);
if (NS_FAILED(rv)) return rv;
rv = mListener->OnDataAvailable(request, aContext,
inputData, 0, mBuffer.Length());
if (NS_FAILED(rv)) return rv;
mBuffer.Truncate();
return rv;
}
NS_IMETHODIMP
nsTXTToHTMLConv::OnStopRequest(nsIRequest* request, nsISupports *aContext,
nsresult aStatus)
{
nsresult rv = NS_OK;
if (mToken) {
// we still have an outstanding token
NS_ASSERTION(mToken->prepend,
"Non prepending tokens should be handled in "
"OnDataAvailable. There should only be a single "
"prepending token left to be processed.");
(void)CatHTML(0, mBuffer.Length());
}
if (mPreFormatHTML) {
mBuffer.AppendLiteral("</pre>\n");
}
mBuffer.AppendLiteral("\n</body></html>");
nsCOMPtr<nsIInputStream> inputData;
NS_LossyConvertUTF16toASCII asciiData(mBuffer);
rv = NS_NewCStringInputStream(getter_AddRefs(inputData), asciiData);
if (NS_FAILED(rv)) return rv;
rv = mListener->OnDataAvailable(request, aContext,
inputData, 0, mBuffer.Length());
if (NS_FAILED(rv)) return rv;
return mListener->OnStopRequest(request, aContext, aStatus);
}
// nsITXTToHTMLConv methods
NS_IMETHODIMP
nsTXTToHTMLConv::SetTitle(const char16_t *aTitle)
{
mPageTitle.Assign(aTitle);
return NS_OK;
}
NS_IMETHODIMP
nsTXTToHTMLConv::PreFormatHTML(bool value)
{
mPreFormatHTML = value;
return NS_OK;
}
// nsIStreamListener method
NS_IMETHODIMP
nsTXTToHTMLConv::OnDataAvailable(nsIRequest* request, nsISupports *aContext,
nsIInputStream *aInStream,
uint64_t aOffset, uint32_t aCount)
{
nsresult rv = NS_OK;
nsString pushBuffer;
uint32_t amtRead = 0;
auto buffer = MakeUniqueFallible<char[]>(aCount+1);
if (!buffer) return NS_ERROR_OUT_OF_MEMORY;
do {
uint32_t read = 0;
// XXX readSegments, to avoid the first copy?
rv = aInStream->Read(buffer.get(), aCount-amtRead, &read);
if (NS_FAILED(rv)) return rv;
buffer[read] = '\0';
// XXX charsets?? non-latin1 characters?? utf-16??
AppendASCIItoUTF16(buffer.get(), mBuffer);
amtRead += read;
int32_t front = -1, back = -1, tokenLoc = -1, cursor = 0;
while ( (tokenLoc = FindToken(cursor, &mToken)) > -1) {
if (mToken->prepend) {
front = mBuffer.RFindCharInSet(TOKEN_DELIMITERS, tokenLoc);
front++;
back = mBuffer.FindCharInSet(TOKEN_DELIMITERS, tokenLoc);
} else {
front = tokenLoc;
back = front + mToken->token.Length();
}
if (back == -1) {
// didn't find an ending, buffer up.
mBuffer.Left(pushBuffer, front);
cursor = front;
break;
}
// found the end of the token.
cursor = CatHTML(front, back);
}
int32_t end = mBuffer.RFind(TOKEN_DELIMITERS, mBuffer.Length());
mBuffer.Left(pushBuffer, std::max(cursor, end));
mBuffer.Cut(0, std::max(cursor, end));
cursor = 0;
if (!pushBuffer.IsEmpty()) {
nsCOMPtr<nsIInputStream> inputData;
NS_LossyConvertUTF16toASCII asciiData(pushBuffer);
rv = NS_NewCStringInputStream(getter_AddRefs(inputData), asciiData);
if (NS_FAILED(rv))
return rv;
rv = mListener->OnDataAvailable(request, aContext,
inputData, 0, pushBuffer.Length());
if (NS_FAILED(rv))
return rv;
}
} while (amtRead < aCount);
return rv;
}
// nsTXTToHTMLConv methods
nsTXTToHTMLConv::nsTXTToHTMLConv()
{
mToken = nullptr;
mPreFormatHTML = false;
}
nsTXTToHTMLConv::~nsTXTToHTMLConv()
{
mTokens.Clear();
}
nsresult
nsTXTToHTMLConv::Init()
{
nsresult rv = NS_OK;
// build up the list of tokens to handle
convToken *token = new convToken;
if (!token) return NS_ERROR_OUT_OF_MEMORY;
token->prepend = false;
token->token.Assign(char16_t('<'));
token->modText.AssignLiteral("&lt;");
mTokens.AppendElement(token);
token = new convToken;
if (!token) return NS_ERROR_OUT_OF_MEMORY;
token->prepend = false;
token->token.Assign(char16_t('>'));
token->modText.AssignLiteral("&gt;");
mTokens.AppendElement(token);
token = new convToken;
if (!token) return NS_ERROR_OUT_OF_MEMORY;
token->prepend = false;
token->token.Assign(char16_t('&'));
token->modText.AssignLiteral("&amp;");
mTokens.AppendElement(token);
token = new convToken;
if (!token) return NS_ERROR_OUT_OF_MEMORY;
token->prepend = true;
token->token.AssignLiteral("http://"); // XXX need to iterate through all protos
mTokens.AppendElement(token);
token = new convToken;
if (!token) return NS_ERROR_OUT_OF_MEMORY;
token->prepend = true;
token->token.Assign(char16_t('@'));
token->modText.AssignLiteral("mailto:");
mTokens.AppendElement(token);
return rv;
}
int32_t
nsTXTToHTMLConv::FindToken(int32_t cursor, convToken* *_retval)
{
int32_t loc = -1, firstToken = mBuffer.Length();
int8_t token = -1;
for (uint8_t i=0; i < mTokens.Length(); i++) {
loc = mBuffer.Find(mTokens[i]->token, cursor);
if (loc != -1)
if (loc < firstToken) {
firstToken = loc;
token = i;
}
}
if (token == -1)
return -1;
*_retval = mTokens[token];
return firstToken;
}
int32_t
nsTXTToHTMLConv::CatHTML(int32_t front, int32_t back)
{
int32_t cursor = 0;
int32_t modLen = mToken->modText.Length();
if (!mToken->prepend) {
// replace the entire token (from delimiter to delimiter)
mBuffer.Cut(front, back - front);
mBuffer.Insert(mToken->modText, front);
cursor = front+modLen;
} else {
nsString linkText;
// href is implied
mBuffer.Mid(linkText, front, back-front);
mBuffer.Insert(NS_LITERAL_STRING("<a href=\""), front);
cursor += front+9;
if (modLen) {
mBuffer.Insert(mToken->modText, cursor);
cursor += modLen;
}
NS_ConvertUTF16toUTF8 linkTextUTF8(linkText);
nsCString escaped;
if (NS_EscapeURL(linkTextUTF8.Data(), linkTextUTF8.Length(), esc_Minimal, escaped)) {
mBuffer.Cut(cursor, back - front);
CopyUTF8toUTF16(escaped, linkText);
mBuffer.Insert(linkText, cursor);
back = front + linkText.Length();
}
cursor += back-front;
mBuffer.Insert(NS_LITERAL_STRING("\">"), cursor);
cursor += 2;
mBuffer.Insert(linkText, cursor);
cursor += linkText.Length();
mBuffer.Insert(NS_LITERAL_STRING("</a>"), cursor);
cursor += 4;
}
mToken = nullptr; // indicates completeness
return cursor;
}

View file

@ -0,0 +1,89 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef ____nstxttohtmlconv___h___
#define ____nstxttohtmlconv___h___
#include "nsITXTToHTMLConv.h"
#include "nsCOMPtr.h"
#include "nsTArray.h"
#include "nsString.h"
#define NS_NSTXTTOHTMLCONVERTER_CID \
{ /* 9ef9fa14-1dd1-11b2-9d65-d72d6d1f025e */ \
0x9ef9fa14, \
0x1dd1, \
0x11b2, \
{0x9d, 0x65, 0xd7, 0x2d, 0x6d, 0x1f, 0x02, 0x5e} \
}
// Internal representation of a "token"
typedef struct convToken {
nsString token; // the actual string (i.e. "http://")
nsString modText; // replacement text or href prepend text.
bool prepend; // flag indicating how the modText should be used.
} convToken;
template<class T> class nsAutoPtr;
/**
* Convert plain text to HTML.
*
* OVERVIEW OF HOW THIS CLASS WORKS:
*
* This class stores an array of tokens that should be replaced by something,
* or something that should be prepended.
* The "token" member of convToken is the text to search for. This is a
* substring of the desired token. Tokens are delimited by TOKEN_DELIMITERS.
* That entire token will be replaced by modText (if prepend is false); or it
* will be linkified and modText will be prepended to the token if prepend is
* true.
*
* Note that all of the text will be in a preformatted block, so there is no
* need to emit line-end tags, or set the font face to monospace.
*
* This works as a stream converter, so data will arrive by
* OnStartRequest/OnDataAvailable/OnStopRequest calls.
*
* OStopR will possibly process a remaining token.
*
* If the data of one pass contains a part of a token, that part will be stored
* in mBuffer. The rest of the data will be sent to the next listener.
*
* XXX this seems suboptimal. this means that this design will only work for
* links. and it is impossible to append anything to the token. this means that,
* for example, making *foo* bold is not possible.
*/
class nsTXTToHTMLConv : public nsITXTToHTMLConv {
public:
NS_DECL_ISUPPORTS
NS_DECL_NSISTREAMCONVERTER
NS_DECL_NSITXTTOHTMLCONV
NS_DECL_NSIREQUESTOBSERVER
NS_DECL_NSISTREAMLISTENER
nsTXTToHTMLConv();
nsresult Init();
protected:
virtual ~nsTXTToHTMLConv();
// return the token and it's location in the underlying buffer.
int32_t FindToken(int32_t cursor, convToken* *_retval);
// return the cursor location after munging HTML into the
// underlying buffer, according to mToken
int32_t CatHTML(int32_t front, int32_t back);
nsCOMPtr<nsIStreamListener> mListener; // final listener (consumer)
nsString mBuffer; // any carry over data
nsTArray<nsAutoPtr<convToken> > mTokens; // list of tokens to search for
convToken *mToken; // current token (if any)
nsString mPageTitle; // Page title
bool mPreFormatHTML; // Whether to use <pre> tags
};
#endif // ____nstxttohtmlconv___h___

View file

@ -0,0 +1,836 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsUnknownDecoder.h"
#include "nsIPipe.h"
#include "nsIInputStream.h"
#include "nsIOutputStream.h"
#include "nsMimeTypes.h"
#include "nsIPrefService.h"
#include "nsIPrefBranch.h"
#include "nsCRT.h"
#include "nsIMIMEService.h"
#include "nsIDivertableChannel.h"
#include "nsIViewSourceChannel.h"
#include "nsIHttpChannel.h"
#include "nsIForcePendingChannel.h"
#include "nsIEncodedChannel.h"
#include "nsIURI.h"
#include "nsStringStream.h"
#include "nsNetCID.h"
#include "nsNetUtil.h"
#include <algorithm>
#define MAX_BUFFER_SIZE 512u
NS_IMPL_ISUPPORTS(nsUnknownDecoder::ConvertedStreamListener,
nsIStreamListener,
nsIRequestObserver)
nsUnknownDecoder::ConvertedStreamListener::
ConvertedStreamListener(nsUnknownDecoder *aDecoder)
{
mDecoder = aDecoder;
}
nsUnknownDecoder::ConvertedStreamListener::~ConvertedStreamListener()
{
}
nsresult
nsUnknownDecoder::ConvertedStreamListener::
AppendDataToString(nsIInputStream* inputStream,
void* closure,
const char* rawSegment,
uint32_t toOffset,
uint32_t count,
uint32_t* writeCount)
{
nsCString* decodedData = static_cast<nsCString*>(closure);
decodedData->Append(rawSegment, count);
*writeCount = count;
return NS_OK;
}
NS_IMETHODIMP
nsUnknownDecoder::ConvertedStreamListener::OnStartRequest(nsIRequest* request,
nsISupports* context)
{
return NS_OK;
}
NS_IMETHODIMP
nsUnknownDecoder::ConvertedStreamListener::
OnDataAvailable(nsIRequest* request,
nsISupports* context,
nsIInputStream* stream,
uint64_t offset,
uint32_t count)
{
uint32_t read;
return stream->ReadSegments(AppendDataToString, &mDecoder->mDecodedData, count,
&read);
}
NS_IMETHODIMP
nsUnknownDecoder::ConvertedStreamListener::OnStopRequest(nsIRequest* request,
nsISupports* context,
nsresult status)
{
return NS_OK;
}
nsUnknownDecoder::nsUnknownDecoder()
: mBuffer(nullptr)
, mBufferLen(0)
, mRequireHTMLsuffix(false)
, mDecodedData("")
{
nsCOMPtr<nsIPrefBranch> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
if (prefs) {
bool val;
if (NS_SUCCEEDED(prefs->GetBoolPref("security.requireHTMLsuffix", &val)))
mRequireHTMLsuffix = val;
}
}
nsUnknownDecoder::~nsUnknownDecoder()
{
if (mBuffer) {
delete [] mBuffer;
mBuffer = nullptr;
}
}
// ----
//
// nsISupports implementation...
//
// ----
NS_IMPL_ADDREF(nsUnknownDecoder)
NS_IMPL_RELEASE(nsUnknownDecoder)
NS_INTERFACE_MAP_BEGIN(nsUnknownDecoder)
NS_INTERFACE_MAP_ENTRY(nsIStreamConverter)
NS_INTERFACE_MAP_ENTRY(nsIStreamListener)
NS_INTERFACE_MAP_ENTRY(nsIRequestObserver)
NS_INTERFACE_MAP_ENTRY(nsIContentSniffer)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIStreamListener)
NS_INTERFACE_MAP_END
// ----
//
// nsIStreamConverter methods...
//
// ----
NS_IMETHODIMP
nsUnknownDecoder::Convert(nsIInputStream *aFromStream,
const char *aFromType,
const char *aToType,
nsISupports *aCtxt,
nsIInputStream **aResultStream)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsUnknownDecoder::AsyncConvertData(const char *aFromType,
const char *aToType,
nsIStreamListener *aListener,
nsISupports *aCtxt)
{
NS_ASSERTION(aListener && aFromType && aToType,
"null pointer passed into multi mixed converter");
// hook up our final listener. this guy gets the various On*() calls we want to throw
// at him.
//
mNextListener = aListener;
return (aListener) ? NS_OK : NS_ERROR_FAILURE;
}
// ----
//
// nsIStreamListener methods...
//
// ----
NS_IMETHODIMP
nsUnknownDecoder::OnDataAvailable(nsIRequest* request,
nsISupports *aCtxt,
nsIInputStream *aStream,
uint64_t aSourceOffset,
uint32_t aCount)
{
nsresult rv = NS_OK;
if (!mNextListener) return NS_ERROR_FAILURE;
if (mContentType.IsEmpty()) {
uint32_t count, len;
// If the buffer has not been allocated by now, just fail...
if (!mBuffer) return NS_ERROR_OUT_OF_MEMORY;
//
// Determine how much of the stream should be read to fill up the
// sniffer buffer...
//
if (mBufferLen + aCount >= MAX_BUFFER_SIZE) {
count = MAX_BUFFER_SIZE-mBufferLen;
} else {
count = aCount;
}
// Read the data into the buffer...
rv = aStream->Read((mBuffer+mBufferLen), count, &len);
if (NS_FAILED(rv)) return rv;
mBufferLen += len;
aCount -= len;
if (aCount) {
//
// Adjust the source offset... The call to FireListenerNotifications(...)
// will make the first OnDataAvailable(...) call with an offset of 0.
// So, this offset needs to be adjusted to reflect that...
//
aSourceOffset += mBufferLen;
DetermineContentType(request);
rv = FireListenerNotifications(request, aCtxt);
}
}
// Must not fire ODA again if it failed once
if (aCount && NS_SUCCEEDED(rv)) {
NS_ASSERTION(!mContentType.IsEmpty(),
"Content type should be known by now.");
nsCOMPtr<nsIDivertableChannel> divertable = do_QueryInterface(request);
if (divertable) {
bool diverting;
divertable->GetDivertingToParent(&diverting);
if (diverting) {
// The channel is diverted to the parent do not send any more data here.
return rv;
}
}
rv = mNextListener->OnDataAvailable(request, aCtxt, aStream,
aSourceOffset, aCount);
}
return rv;
}
// ----
//
// nsIRequestObserver methods...
//
// ----
NS_IMETHODIMP
nsUnknownDecoder::OnStartRequest(nsIRequest* request, nsISupports *aCtxt)
{
nsresult rv = NS_OK;
if (!mNextListener) return NS_ERROR_FAILURE;
// Allocate the sniffer buffer...
if (NS_SUCCEEDED(rv) && !mBuffer) {
mBuffer = new char[MAX_BUFFER_SIZE];
if (!mBuffer) {
rv = NS_ERROR_OUT_OF_MEMORY;
}
}
nsCOMPtr<nsIDivertableChannel> divertable = do_QueryInterface(request);
if (divertable) {
divertable->UnknownDecoderInvolvedKeepData();
}
// Do not pass the OnStartRequest on to the next listener (yet)...
return rv;
}
NS_IMETHODIMP
nsUnknownDecoder::OnStopRequest(nsIRequest* request, nsISupports *aCtxt,
nsresult aStatus)
{
nsresult rv = NS_OK;
if (!mNextListener) return NS_ERROR_FAILURE;
//
// The total amount of data is less than the size of the sniffer buffer.
// Analyze the buffer now...
//
if (mContentType.IsEmpty()) {
DetermineContentType(request);
// Make sure channel listeners see channel as pending while we call
// OnStartRequest/OnDataAvailable, even though the underlying channel
// has already hit OnStopRequest.
nsCOMPtr<nsIForcePendingChannel> forcePendingChannel = do_QueryInterface(request);
if (forcePendingChannel) {
forcePendingChannel->ForcePending(true);
}
rv = FireListenerNotifications(request, aCtxt);
if (NS_FAILED(rv)) {
aStatus = rv;
}
// now we need to set pending state to false before calling OnStopRequest
if (forcePendingChannel) {
forcePendingChannel->ForcePending(false);
}
}
rv = mNextListener->OnStopRequest(request, aCtxt, aStatus);
mNextListener = nullptr;
return rv;
}
// ----
//
// nsIContentSniffer methods...
//
// ----
NS_IMETHODIMP
nsUnknownDecoder::GetMIMETypeFromContent(nsIRequest* aRequest,
const uint8_t* aData,
uint32_t aLength,
nsACString& type)
{
mBuffer = const_cast<char*>(reinterpret_cast<const char*>(aData));
mBufferLen = aLength;
DetermineContentType(aRequest);
mBuffer = nullptr;
mBufferLen = 0;
type.Assign(mContentType);
mContentType.Truncate();
return type.IsEmpty() ? NS_ERROR_NOT_AVAILABLE : NS_OK;
}
// Actual sniffing code
bool nsUnknownDecoder::AllowSniffing(nsIRequest* aRequest)
{
if (!mRequireHTMLsuffix) {
return true;
}
nsCOMPtr<nsIChannel> channel = do_QueryInterface(aRequest);
if (!channel) {
NS_ERROR("QI failed");
return false;
}
nsCOMPtr<nsIURI> uri;
if (NS_FAILED(channel->GetURI(getter_AddRefs(uri))) || !uri) {
return false;
}
bool isLocalFile = false;
if (NS_FAILED(uri->SchemeIs("file", &isLocalFile)) || isLocalFile) {
return false;
}
return true;
}
/**
* This is the array of sniffer entries that depend on "magic numbers"
* in the file. Each entry has either a type associated with it (set
* these with the SNIFFER_ENTRY macro) or a function to be executed
* (set these with the SNIFFER_ENTRY_WITH_FUNC macro). The function
* should take a single nsIRequest* and returns bool -- true if
* it sets mContentType, false otherwise
*/
nsUnknownDecoder::nsSnifferEntry nsUnknownDecoder::sSnifferEntries[] = {
SNIFFER_ENTRY("%PDF-", APPLICATION_PDF),
SNIFFER_ENTRY("%!PS-Adobe-", APPLICATION_POSTSCRIPT),
// Files that start with mailbox delimiters let's provisionally call
// text/plain
SNIFFER_ENTRY("From", TEXT_PLAIN),
SNIFFER_ENTRY(">From", TEXT_PLAIN),
// If the buffer begins with "#!" or "%!" then it is a script of
// some sort... "Scripts" can include arbitrary data to be passed
// to an interpreter, so we need to decide whether we can call this
// text or whether it's data.
SNIFFER_ENTRY_WITH_FUNC("#!", &nsUnknownDecoder::LastDitchSniff),
// XXXbz should (and can) we also include the various ways that <?xml can
// appear as UTF-16 and such? See http://www.w3.org/TR/REC-xml#sec-guessing
SNIFFER_ENTRY_WITH_FUNC("<?xml", &nsUnknownDecoder::SniffForXML)
};
uint32_t nsUnknownDecoder::sSnifferEntryNum =
sizeof(nsUnknownDecoder::sSnifferEntries) /
sizeof(nsUnknownDecoder::nsSnifferEntry);
void nsUnknownDecoder::DetermineContentType(nsIRequest* aRequest)
{
NS_ASSERTION(mContentType.IsEmpty(), "Content type is already known.");
if (!mContentType.IsEmpty()) return;
const char* testData = mBuffer;
uint32_t testDataLen = mBufferLen;
// Check if data are compressed.
nsCOMPtr<nsIHttpChannel> channel(do_QueryInterface(aRequest));
if (channel) {
nsresult rv = ConvertEncodedData(aRequest, mBuffer, mBufferLen);
if (NS_SUCCEEDED(rv)) {
if (!mDecodedData.IsEmpty()) {
testData = mDecodedData.get();
testDataLen = std::min(mDecodedData.Length(), MAX_BUFFER_SIZE);
}
}
}
// First, run through all the types we can detect reliably based on
// magic numbers
uint32_t i;
for (i = 0; i < sSnifferEntryNum; ++i) {
if (testDataLen >= sSnifferEntries[i].mByteLen && // enough data
memcmp(testData, sSnifferEntries[i].mBytes, sSnifferEntries[i].mByteLen) == 0) { // and type matches
NS_ASSERTION(sSnifferEntries[i].mMimeType ||
sSnifferEntries[i].mContentTypeSniffer,
"Must have either a type string or a function to set the type");
NS_ASSERTION(!sSnifferEntries[i].mMimeType ||
!sSnifferEntries[i].mContentTypeSniffer,
"Both a type string and a type sniffing function set;"
" using type string");
if (sSnifferEntries[i].mMimeType) {
mContentType = sSnifferEntries[i].mMimeType;
NS_ASSERTION(!mContentType.IsEmpty(),
"Content type should be known by now.");
return;
}
if ((this->*(sSnifferEntries[i].mContentTypeSniffer))(aRequest)) {
NS_ASSERTION(!mContentType.IsEmpty(),
"Content type should be known by now.");
return;
}
}
}
NS_SniffContent(NS_DATA_SNIFFER_CATEGORY, aRequest,
(const uint8_t*)testData, testDataLen, mContentType);
if (!mContentType.IsEmpty()) {
return;
}
if (SniffForHTML(aRequest)) {
NS_ASSERTION(!mContentType.IsEmpty(),
"Content type should be known by now.");
return;
}
// We don't know what this is yet. Before we just give up, try
// the URI from the request.
if (SniffURI(aRequest)) {
NS_ASSERTION(!mContentType.IsEmpty(),
"Content type should be known by now.");
return;
}
LastDitchSniff(aRequest);
NS_ASSERTION(!mContentType.IsEmpty(),
"Content type should be known by now.");
}
bool nsUnknownDecoder::SniffForHTML(nsIRequest* aRequest)
{
/*
* To prevent a possible attack, we will not consider this to be
* html content if it comes from the local file system and our prefs
* are set right
*/
if (!AllowSniffing(aRequest)) {
return false;
}
// Now look for HTML.
const char* str;
const char* end;
if (mDecodedData.IsEmpty()) {
str = mBuffer;
end = mBuffer + mBufferLen;
} else {
str = mDecodedData.get();
end = mDecodedData.get() + std::min(mDecodedData.Length(),
MAX_BUFFER_SIZE);
}
// skip leading whitespace
while (str != end && nsCRT::IsAsciiSpace(*str)) {
++str;
}
// did we find something like a start tag?
if (str == end || *str != '<' || ++str == end) {
return false;
}
// If we seem to be SGML or XML and we got down here, just pretend we're HTML
if (*str == '!' || *str == '?') {
mContentType = TEXT_HTML;
return true;
}
uint32_t bufSize = end - str;
// We use sizeof(_tagstr) below because that's the length of _tagstr
// with the one char " " or ">" appended.
#define MATCHES_TAG(_tagstr) \
(bufSize >= sizeof(_tagstr) && \
(PL_strncasecmp(str, _tagstr " ", sizeof(_tagstr)) == 0 || \
PL_strncasecmp(str, _tagstr ">", sizeof(_tagstr)) == 0))
if (MATCHES_TAG("html") ||
MATCHES_TAG("frameset") ||
MATCHES_TAG("body") ||
MATCHES_TAG("head") ||
MATCHES_TAG("script") ||
MATCHES_TAG("iframe") ||
MATCHES_TAG("a") ||
MATCHES_TAG("img") ||
MATCHES_TAG("table") ||
MATCHES_TAG("title") ||
MATCHES_TAG("link") ||
MATCHES_TAG("base") ||
MATCHES_TAG("style") ||
MATCHES_TAG("div") ||
MATCHES_TAG("p") ||
MATCHES_TAG("font") ||
MATCHES_TAG("applet") ||
MATCHES_TAG("meta") ||
MATCHES_TAG("center") ||
MATCHES_TAG("form") ||
MATCHES_TAG("isindex") ||
MATCHES_TAG("h1") ||
MATCHES_TAG("h2") ||
MATCHES_TAG("h3") ||
MATCHES_TAG("h4") ||
MATCHES_TAG("h5") ||
MATCHES_TAG("h6") ||
MATCHES_TAG("b") ||
MATCHES_TAG("pre")) {
mContentType = TEXT_HTML;
return true;
}
#undef MATCHES_TAG
return false;
}
bool nsUnknownDecoder::SniffForXML(nsIRequest* aRequest)
{
// Just like HTML, this should be able to be shut off.
if (!AllowSniffing(aRequest)) {
return false;
}
// First see whether we can glean anything from the uri...
if (!SniffURI(aRequest)) {
// Oh well; just generic XML will have to do
mContentType = TEXT_XML;
}
return true;
}
bool nsUnknownDecoder::SniffURI(nsIRequest* aRequest)
{
nsCOMPtr<nsIMIMEService> mimeService(do_GetService("@mozilla.org/mime;1"));
if (mimeService) {
nsCOMPtr<nsIChannel> channel = do_QueryInterface(aRequest);
if (channel) {
nsCOMPtr<nsIURI> uri;
nsresult result = channel->GetURI(getter_AddRefs(uri));
if (NS_SUCCEEDED(result) && uri) {
nsAutoCString type;
result = mimeService->GetTypeFromURI(uri, type);
if (NS_SUCCEEDED(result)) {
mContentType = type;
return true;
}
}
}
}
return false;
}
// This macro is based on RFC 2046 Section 4.1.2. Treat any char 0-31
// except the 9-13 range (\t, \n, \v, \f, \r) and char 27 (used by
// encodings like Shift_JIS) as non-text
#define IS_TEXT_CHAR(ch) \
(((unsigned char)(ch)) > 31 || (9 <= (ch) && (ch) <= 13) || (ch) == 27)
bool nsUnknownDecoder::LastDitchSniff(nsIRequest* aRequest)
{
// All we can do now is try to guess whether this is text/plain or
// application/octet-stream
const char* testData;
uint32_t testDataLen;
if (mDecodedData.IsEmpty()) {
testData = mBuffer;
testDataLen = mBufferLen;
} else {
testData = mDecodedData.get();
testDataLen = std::min(mDecodedData.Length(), MAX_BUFFER_SIZE);
}
// First, check for a BOM. If we see one, assume this is text/plain
// in whatever encoding. If there is a BOM _and_ text we will
// always have at least 4 bytes in the buffer (since the 2-byte BOMs
// are for 2-byte encodings and the UTF-8 BOM is 3 bytes).
if (testDataLen >= 4) {
const unsigned char* buf = (const unsigned char*)testData;
if ((buf[0] == 0xFE && buf[1] == 0xFF) || // UTF-16, Big Endian
(buf[0] == 0xFF && buf[1] == 0xFE) || // UTF-16 or UCS-4, Little Endian
(buf[0] == 0xEF && buf[1] == 0xBB && buf[2] == 0xBF) || // UTF-8
(buf[0] == 0 && buf[1] == 0 && buf[2] == 0xFE && buf[3] == 0xFF)) { // UCS-4, Big Endian
mContentType = TEXT_PLAIN;
return true;
}
}
// Now see whether the buffer has any non-text chars. If not, then let's
// just call it text/plain...
//
uint32_t i;
for (i = 0; i < testDataLen && IS_TEXT_CHAR(testData[i]); i++) {
continue;
}
if (i == testDataLen) {
mContentType = TEXT_PLAIN;
}
else {
mContentType = APPLICATION_OCTET_STREAM;
}
return true;
}
nsresult nsUnknownDecoder::FireListenerNotifications(nsIRequest* request,
nsISupports *aCtxt)
{
nsresult rv = NS_OK;
if (!mNextListener) return NS_ERROR_FAILURE;
if (!mContentType.IsEmpty()) {
nsCOMPtr<nsIViewSourceChannel> viewSourceChannel =
do_QueryInterface(request);
if (viewSourceChannel) {
rv = viewSourceChannel->SetOriginalContentType(mContentType);
} else {
nsCOMPtr<nsIChannel> channel = do_QueryInterface(request, &rv);
if (NS_SUCCEEDED(rv)) {
// Set the new content type on the channel...
rv = channel->SetContentType(mContentType);
}
}
NS_ASSERTION(NS_SUCCEEDED(rv), "Unable to set content type on channel!");
if (NS_FAILED(rv)) {
// Cancel the request to make sure it has the correct status if
// mNextListener looks at it.
request->Cancel(rv);
mNextListener->OnStartRequest(request, aCtxt);
nsCOMPtr<nsIDivertableChannel> divertable = do_QueryInterface(request);
if (divertable) {
rv = divertable->UnknownDecoderInvolvedOnStartRequestCalled();
}
return rv;
}
}
// Fire the OnStartRequest(...)
rv = mNextListener->OnStartRequest(request, aCtxt);
nsCOMPtr<nsIDivertableChannel> divertable = do_QueryInterface(request);
if (divertable) {
rv = divertable->UnknownDecoderInvolvedOnStartRequestCalled();
bool diverting;
divertable->GetDivertingToParent(&diverting);
if (diverting) {
// The channel is diverted to the parent do not send any more data here.
return rv;
}
}
if (NS_SUCCEEDED(rv)) {
// install stream converter if required
nsCOMPtr<nsIEncodedChannel> encodedChannel = do_QueryInterface(request);
if (encodedChannel) {
nsCOMPtr<nsIStreamListener> listener;
rv = encodedChannel->DoApplyContentConversions(mNextListener, getter_AddRefs(listener), aCtxt);
if (NS_SUCCEEDED(rv) && listener) {
mNextListener = listener;
}
}
}
if (!mBuffer) return NS_ERROR_OUT_OF_MEMORY;
// If the request was canceled, then we need to treat that equivalently
// to an error returned by OnStartRequest.
if (NS_SUCCEEDED(rv))
request->GetStatus(&rv);
// Fire the first OnDataAvailable for the data that was read from the
// stream into the sniffer buffer...
if (NS_SUCCEEDED(rv) && (mBufferLen > 0)) {
uint32_t len = 0;
nsCOMPtr<nsIInputStream> in;
nsCOMPtr<nsIOutputStream> out;
// Create a pipe and fill it with the data from the sniffer buffer.
rv = NS_NewPipe(getter_AddRefs(in), getter_AddRefs(out),
MAX_BUFFER_SIZE, MAX_BUFFER_SIZE);
if (NS_SUCCEEDED(rv)) {
rv = out->Write(mBuffer, mBufferLen, &len);
if (NS_SUCCEEDED(rv)) {
if (len == mBufferLen) {
rv = mNextListener->OnDataAvailable(request, aCtxt, in, 0, len);
} else {
NS_ERROR("Unable to write all the data into the pipe.");
rv = NS_ERROR_FAILURE;
}
}
}
}
delete [] mBuffer;
mBuffer = nullptr;
mBufferLen = 0;
return rv;
}
nsresult
nsUnknownDecoder::ConvertEncodedData(nsIRequest* request,
const char* data,
uint32_t length)
{
nsresult rv = NS_OK;
mDecodedData = "";
nsCOMPtr<nsIEncodedChannel> encodedChannel(do_QueryInterface(request));
if (encodedChannel) {
RefPtr<ConvertedStreamListener> strListener =
new ConvertedStreamListener(this);
nsCOMPtr<nsIStreamListener> listener;
rv = encodedChannel->DoApplyContentConversions(strListener,
getter_AddRefs(listener),
nullptr);
if (NS_FAILED(rv)) {
return rv;
}
if (listener) {
listener->OnStartRequest(request, nullptr);
nsCOMPtr<nsIStringInputStream> rawStream =
do_CreateInstance(NS_STRINGINPUTSTREAM_CONTRACTID);
if (!rawStream)
return NS_ERROR_FAILURE;
rv = rawStream->SetData((const char*)data, length);
NS_ENSURE_SUCCESS(rv, rv);
rv = listener->OnDataAvailable(request, nullptr, rawStream, 0,
length);
NS_ENSURE_SUCCESS(rv, rv);
listener->OnStopRequest(request, nullptr, NS_OK);
}
}
return rv;
}
void
nsBinaryDetector::DetermineContentType(nsIRequest* aRequest)
{
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(aRequest);
if (!httpChannel) {
return;
}
// It's an HTTP channel. Check for the text/plain mess
nsAutoCString contentTypeHdr;
httpChannel->GetResponseHeader(NS_LITERAL_CSTRING("Content-Type"),
contentTypeHdr);
nsAutoCString contentType;
httpChannel->GetContentType(contentType);
// Make sure to do a case-sensitive exact match comparison here. Apache
// 1.x just sends text/plain for "unknown", while Apache 2.x sends
// text/plain with a ISO-8859-1 charset. Debian's Apache version, just to
// be different, sends text/plain with iso-8859-1 charset. For extra fun,
// FC7, RHEL4, and Ubuntu Feisty send charset=UTF-8. Don't do general
// case-insensitive comparison, since we really want to apply this crap as
// rarely as we can.
if (!contentType.EqualsLiteral("text/plain") ||
(!contentTypeHdr.EqualsLiteral("text/plain") &&
!contentTypeHdr.EqualsLiteral("text/plain; charset=ISO-8859-1") &&
!contentTypeHdr.EqualsLiteral("text/plain; charset=iso-8859-1") &&
!contentTypeHdr.EqualsLiteral("text/plain; charset=UTF-8"))) {
return;
}
// Check whether we have content-encoding. If we do, don't try to
// detect the type.
// XXXbz we could improve this by doing a local decompress if we
// wanted, I'm sure.
nsAutoCString contentEncoding;
httpChannel->GetResponseHeader(NS_LITERAL_CSTRING("Content-Encoding"),
contentEncoding);
if (!contentEncoding.IsEmpty()) {
return;
}
LastDitchSniff(aRequest);
if (mContentType.Equals(APPLICATION_OCTET_STREAM)) {
// We want to guess at it instead
mContentType = APPLICATION_GUESS_FROM_EXT;
} else {
// Let the text/plain type we already have be, so that other content
// sniffers can also get a shot at this data.
mContentType.Truncate();
}
}

View file

@ -0,0 +1,159 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nsUnknownDecoder_h__
#define nsUnknownDecoder_h__
#include "nsIStreamConverter.h"
#include "nsIContentSniffer.h"
#include "nsCOMPtr.h"
#include "nsString.h"
#define NS_UNKNOWNDECODER_CID \
{ /* 7d7008a0-c49a-11d3-9b22-0080c7cb1080 */ \
0x7d7008a0, \
0xc49a, \
0x11d3, \
{0x9b, 0x22, 0x00, 0x80, 0xc7, 0xcb, 0x10, 0x80} \
}
class nsUnknownDecoder : public nsIStreamConverter, public nsIContentSniffer
{
public:
// nsISupports methods
NS_DECL_ISUPPORTS
// nsIStreamConverter methods
NS_DECL_NSISTREAMCONVERTER
// nsIStreamListener methods
NS_DECL_NSISTREAMLISTENER
// nsIRequestObserver methods
NS_DECL_NSIREQUESTOBSERVER
// nsIContentSniffer methods
NS_DECL_NSICONTENTSNIFFER
nsUnknownDecoder();
protected:
virtual ~nsUnknownDecoder();
virtual void DetermineContentType(nsIRequest* aRequest);
nsresult FireListenerNotifications(nsIRequest* request, nsISupports *aCtxt);
class ConvertedStreamListener: public nsIStreamListener
{
public:
explicit ConvertedStreamListener(nsUnknownDecoder *aDecoder);
NS_DECL_ISUPPORTS
NS_DECL_NSIREQUESTOBSERVER
NS_DECL_NSISTREAMLISTENER
private:
virtual ~ConvertedStreamListener();
static nsresult AppendDataToString(nsIInputStream* inputStream,
void* closure,
const char* rawSegment,
uint32_t toOffset,
uint32_t count,
uint32_t* writeCount);
nsUnknownDecoder *mDecoder;
};
protected:
nsCOMPtr<nsIStreamListener> mNextListener;
// Function to use to check whether sniffing some potentially
// dangerous types (eg HTML) is ok for this request. We can disable
// sniffing for local files if needed using this. Just a security
// precation thingy... who knows when we suddenly need to flip this
// pref?
bool AllowSniffing(nsIRequest* aRequest);
// Various sniffer functions. Returning true means that a type
// was determined; false means no luck.
bool SniffForHTML(nsIRequest* aRequest);
bool SniffForXML(nsIRequest* aRequest);
// SniffURI guesses at the content type based on the URI (typically
// using the extentsion)
bool SniffURI(nsIRequest* aRequest);
// LastDitchSniff guesses at text/plain vs. application/octet-stream
// by just looking at whether the data contains null bytes, and
// maybe at the fraction of chars with high bit set. Use this only
// as a last-ditch attempt to decide a content type!
bool LastDitchSniff(nsIRequest* aRequest);
/**
* An entry struct for our array of sniffers. Each entry has either
* a type associated with it (set these with the SNIFFER_ENTRY macro)
* or a function to be executed (set these with the
* SNIFFER_ENTRY_WITH_FUNC macro). The function should take a single
* nsIRequest* and returns bool -- true if it sets mContentType,
* false otherwise
*/
struct nsSnifferEntry {
typedef bool (nsUnknownDecoder::*TypeSniffFunc)(nsIRequest* aRequest);
const char* mBytes;
uint32_t mByteLen;
// Exactly one of mMimeType and mContentTypeSniffer should be set non-null
const char* mMimeType;
TypeSniffFunc mContentTypeSniffer;
};
#define SNIFFER_ENTRY(_bytes, _type) \
{ _bytes, sizeof(_bytes) - 1, _type, nullptr }
#define SNIFFER_ENTRY_WITH_FUNC(_bytes, _func) \
{ _bytes, sizeof(_bytes) - 1, nullptr, _func }
static nsSnifferEntry sSnifferEntries[];
static uint32_t sSnifferEntryNum;
char *mBuffer;
uint32_t mBufferLen;
bool mRequireHTMLsuffix;
nsCString mContentType;
protected:
nsresult ConvertEncodedData(nsIRequest* request, const char* data,
uint32_t length);
nsCString mDecodedData; // If data are encoded this will be uncompress data.
};
#define NS_BINARYDETECTOR_CID \
{ /* a2027ec6-ba0d-4c72-805d-148233f5f33c */ \
0xa2027ec6, \
0xba0d, \
0x4c72, \
{0x80, 0x5d, 0x14, 0x82, 0x33, 0xf5, 0xf3, 0x3c} \
}
/**
* Class that detects whether a data stream is text or binary. This reuses
* most of nsUnknownDecoder except the actual content-type determination logic
* -- our overridden DetermineContentType simply calls LastDitchSniff and sets
* the type to APPLICATION_GUESS_FROM_EXT if the data is detected as binary.
*/
class nsBinaryDetector : public nsUnknownDecoder
{
protected:
virtual void DetermineContentType(nsIRequest* aRequest);
};
#define NS_BINARYDETECTOR_CATEGORYENTRY \
{ NS_CONTENT_SNIFFER_CATEGORY, "Binary Detector", NS_BINARYDETECTOR_CONTRACTID }
#endif /* nsUnknownDecoder_h__ */

View file

@ -0,0 +1,30 @@
I couldn't find any SuperTCP or Chameleon/Newt FTP servers, so the
following is based on guesswork from the mirror.pl and lynx projects.
The first 8 are Chameleon/Newt, the remaining 16 entries are SuperTCP
with two different date styles. The precise amount of whitespace
between columns might not be correct, but the parser shouldn't care.
. <DIR> Nov 16 1994 17:16
.. <DIR> Nov 16 1994 17:16
INSTALL <DIR> Nov 16 1994 17:17
CMT <DIR> Nov 21 1994 10:17
DESIGN1.DOC 11264 May 11 1995 14:20 A
README.TXT 1045 May 10 1995 11:01
WPKIT1.EXE 960338 Jun 21 1995 17:01 R
CMT.CSV 0 Jul 06 1995 14:56 RHA
. <DIR> 11-16-94 17:16
.. <DIR> 11-16-94 17:16
INSTALL <DIR> 11-16-94 17:17
CMT <DIR> 11-21-94 10:17
DESIGN1.DOC 11264 05-11-95 14:20
README.TXT 1045 05-10-95 11:01
WPKIT1.EXE 960338 06-21-95 17:01
CMT.CSV 0 07-06-95 14:56
. <DIR> 11/16/94 17:16
.. <DIR> 11/16/94 17:16
INSTALL <DIR> 11/16/94 17:17
CMT <DIR> 11/21/94 10:17
DESIGN1.DOC 11264 05/11/95 14:20
README.TXT 1045 05/10/95 11:01
WPKIT1.EXE 960338 06/21/95 17:01
CMT.CSV 0 07/06/95 14:56

View file

@ -0,0 +1,28 @@
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
11-16-1994 17:16:00 <DIR> .
11-16-1994 17:16:00 <DIR> ..
11-16-1994 17:17:00 <DIR> INSTALL
11-21-1994 10:17:00 <DIR> CMT
05-11-1995 14:20:00 11264 DESIGN1.DOC
05-10-1995 11:01:00 1045 README.TXT
06-21-1995 17:01:00 960338 WPKIT1.EXE
07-06-1995 14:56:00 0 CMT.CSV
11-16-1994 17:16:00 <DIR> .
11-16-1994 17:16:00 <DIR> ..
11-16-1994 17:17:00 <DIR> INSTALL
11-21-1994 10:17:00 <DIR> CMT
05-11-1995 14:20:00 11264 DESIGN1.DOC
05-10-1995 11:01:00 1045 README.TXT
06-21-1995 17:01:00 960338 WPKIT1.EXE
07-06-1995 14:56:00 0 CMT.CSV
11-16-1994 17:16:00 <DIR> .
11-16-1994 17:16:00 <DIR> ..
11-16-1994 17:17:00 <DIR> INSTALL
11-21-1994 10:17:00 <DIR> CMT
05-11-1995 14:20:00 11264 DESIGN1.DOC
05-10-1995 11:01:00 1045 README.TXT
06-21-1995 17:01:00 960338 WPKIT1.EXE
07-06-1995 14:56:00 0 CMT.CSV

View file

@ -0,0 +1,16 @@
This is a synthetic LISTing based on comments in mirror.pl and a
screenshot I saw somewhere. Either way, its 'synthetic' because I
couldn't find an FTP server that LISTed like this. Note that (as
with other VM/CMS LISTings) filesize cannot be determined from
the listing and (AFAIK) files/dirs not on the 'A' minidisk (see
'Fm' field) are not RETRievable/CHDIR'able without magic.
Filename FileType Fm Format Lrecl Records Blocks Date Time
LASTING GLOBALV A1 V 41 21 1 9/16/91 15:10:32
J43401 NETLOG A0 V 77 1 1 9/12/91 12:36:04
PROFILE EXEC A1 V 17 3 1 9/12/91 12:39:07
DIRUNIX SCRIPT A1 V 77 1216 17 1/04/93 20:30:47
MAIL PROFILE A2 F 80 1 1 10/14/92 16:12:27
ABADY2K DATE A0 V 1 1 1 1/03/100 10:11:12
BBADY2K DATE A0 V 1 1 1 11/03/100 10:11:12
AUTHORS A1 DIR - - - 9/20/99 10:31:11

View file

@ -0,0 +1,12 @@
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
09-16-1991 15:10:32 LASTING.GLOBALV
09-12-1991 12:36:04 J43401.NETLOG
09-12-1991 12:39:07 PROFILE.EXEC
01-04-1993 20:30:47 DIRUNIX.SCRIPT
10-14-1992 16:12:27 MAIL.PROFILE
01-03-2000 10:11:12 ABADY2K.DATE
11-03-2000 10:11:12 BBADY2K.DATE
09-20-1999 10:31:11 <DIR> AUTHORS

View file

@ -0,0 +1,61 @@
ftp> open vm.marist.edu
220-Welcome to FTP.Marist.edu
220-
220-All usage logged. Usage restricted.
220-FTPSERVE IBM VM Level 420 at VM.MARIST.EDU, 05:06:00 EDT WEDNESDAY 2002-07-10
220 Connection will close if idle for more than 5 minutes.
Name (vm.marist.edu:cyp):
230-
230-
230-Listserv logs for certain lists are available via CD ACADEM:listname.
230-
230-Lists that they are available for are:
230-
230-ADSM-L ftp://vm.marist.edu/academ:adsm-l./
230-CLINTON ftp://vm.marist.edu/academ:clinton./
230-CMSPIP-L ftp://vm.marist.edu/academ:cmspip-l./
230-CONCORD ftp://vm.marist.edu/academ:concord./
230-REPUB-L ftp://vm.marist.edu/academ:repub-l./
230-SAS-L ftp://vm.marist.edu/academ:sas-l./
230-VM-UTIL ftp://vm.marist.edu/academ:vm-util./
230-LINUX-VM ftp://vm.marist.edu/academ:linux-vm./
230-
230-For example: (Note the trailing .)
230-
230-CD ACADEM:ADSM-L.
230-
230-Due to limitations of Netscape, you may need to append ";type=a"
230-to the end of a URL when obtaining a file.
230-
230-CMS Pipelines RLD available as
230-
230- ftp://vm.marist.edu/academ:pipeline/eweb./
230-
230 ANONYMOU logged in; working directory = ACADEM:ANONYMOU.
Remote system type is z/VM.
ftp> ls
200 Port request OK.
125 List started OK
README ANONYMOU V 71 26 1 1997-04-02 12:33:20 TCP291
README ANONYOLD V 71 15 1 1995-08-25 16:04:27 TCP291
AUTHORS DIR - - - 1999-09-20 10:31:11 -
HARRINGTON DIR - - - 1997-02-12 15:33:28 -
PICS DIR - - - 2000-10-12 15:43:23 -
SYSFILE DIR - - - 2000-07-20 17:48:01 -
WELCNVT EXEC V 72 9 1 1999-09-20 17:16:18 -
WELCOME EREADME F 80 21 1 1999-12-27 16:19:00 -
WELCOME README V 82 21 1 1999-12-27 16:19:04 -
PROJECT PDF V 984 10 3 1997-06-15 11:15:02 -
CAMPUS TIF V 8192 3172 3606 2000-10-06 17:20:37 -
ROTUNDA TIF V 8192 5745 8750 2000-10-06 17:28:25 -
STUDENT TIF V 8192 5017 8557 2000-10-06 17:31:26 -
CHILDREN TXT V 280 310 20 1993-08-06 14:20:00 -
SYSFILE VMARC F 80 2001 40 2000-07-20 17:47:35 -
250 List completed successfully.
ftp> syst
215-z/VM Version 4 Release 2.0, service level 0101 (32-bit)
VM/CMS Level 18, Service Level 101
215 VM is the operating system of this server.
ftp> close
221 Quit command received. Goodbye.
ftp>

View file

@ -0,0 +1,19 @@
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
04-02-1997 12:33:20 README.ANONYMOU
08-25-1995 16:04:27 README.ANONYOLD
09-20-1999 10:31:11 <DIR> AUTHORS
02-12-1997 15:33:28 <DIR> HARRINGTON
10-12-2000 15:43:23 <DIR> PICS
07-20-2000 17:48:01 <DIR> SYSFILE
09-20-1999 17:16:18 WELCNVT.EXEC
12-27-1999 16:19:00 WELCOME.EREADME
12-27-1999 16:19:04 WELCOME.README
06-15-1997 11:15:02 PROJECT.PDF
10-06-2000 17:20:37 CAMPUS.TIF
10-06-2000 17:28:25 ROTUNDA.TIF
10-06-2000 17:31:26 STUDENT.TIF
08-06-1993 14:20:00 CHILDREN.TXT
07-20-2000 17:47:35 SYSFILE.VMARC

View file

@ -0,0 +1,60 @@
ftp> open ftp.microsoft.com
220 Microsoft FTP Service
Name (ftp.microsoft.com:cyp):
331 Anonymous access allowed, send identity (e-mail name) as password.
230-This is FTP.Microsoft.Com
230 Anonymous user logged in.
Remote system type is Windows_NT.
ftp> quote dirstyle
200 MSDOS-like directory output is on
ftp> ls
200 PORT command successful.
150 Opening ASCII mode data connection for /bin/ls.
02-05-01 05:52PM <DIR> 20Year
09-26-00 03:20PM <DIR> AccessFoxPro
12-21-00 02:39PM <DIR> AlbGrp
05-31-01 11:16AM <DIR> Alexandra
01-19-01 09:36AM <DIR> anna
04-06-00 12:53PM <DIR> anz
05-10-00 01:37PM <DIR> Chase Bobko2
03-29-00 02:43PM <DIR> cnn
11-21-00 11:21AM <DIR> Darin
03-09-00 05:55PM <DIR> digitalchicago
09-06-00 11:38AM <DIR> Dublin
01-30-01 07:15PM <DIR> eleanorf
04-26-01 11:04AM <DIR> girvin
04-26-00 09:28PM <DIR> Hires
08-15-00 05:03PM <DIR> HR
10-24-99 01:29AM 4368384 IMG00022.PCD
05-18-01 07:52AM <DIR> jacubowsky
10-12-00 10:55AM <DIR> JFalvey
03-28-01 02:38PM <DIR> johnci
07-14-00 08:59AM <DIR> Karin
09-07-00 05:48PM <DIR> Kjung
09-28-00 08:59AM <DIR> LarryE
08-17-00 06:06PM <DIR> Larson
09-12-00 05:22PM <DIR> marion
08-09-00 12:30PM <DIR> ms25
11-16-00 03:58PM <DIR> MS25Brochure
03-29-00 12:07PM <DIR> MShistory
09-05-00 10:35AM <DIR> Neils
08-02-00 06:25PM <DIR> NLM
09-06-00 03:04PM <DIR> PageOne
06-27-00 06:00PM <DIR> pccomputing
05-09-01 01:27PM <DIR> pictures
07-21-00 04:23PM <DIR> pranks
08-22-00 10:36AM <DIR> Sean
08-10-00 01:54PM <DIR> SLeong
09-07-00 05:46PM <DIR> svr
07-21-00 07:22AM <JUNCTION> a_junction_sample
10-23-00 01:27PM <JUNCTION> b_junction_sample => foo
06-15-00 07:37AM <JUNCTION> c_junction_sample -> bar too
07-14-00 01:35PM 2094926 canprankdesk.tif
07-21-00 01:19PM 95077 Jon Kauffman Enjoys the Good Life.jpg
07-21-00 01:19PM 52275 Name Plate.jpg
07-14-00 01:38PM 2250540 Valentineoffprank-HiRes.jpg
226 Transfer complete.
ftp> close
221 Thank-You For Using Microsoft Products!
ftp>

View file

@ -0,0 +1,47 @@
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
02-05-2001 17:52:00 <DIR> 20Year
09-26-2000 15:20:00 <DIR> AccessFoxPro
12-21-2000 14:39:00 <DIR> AlbGrp
05-31-2001 11:16:00 <DIR> Alexandra
01-19-2001 09:36:00 <DIR> anna
04-06-2000 12:53:00 <DIR> anz
05-10-2000 13:37:00 <DIR> Chase Bobko2
03-29-2000 14:43:00 <DIR> cnn
11-21-2000 11:21:00 <DIR> Darin
03-09-2000 17:55:00 <DIR> digitalchicago
09-06-2000 11:38:00 <DIR> Dublin
01-30-2001 19:15:00 <DIR> eleanorf
04-26-2001 11:04:00 <DIR> girvin
04-26-2000 21:28:00 <DIR> Hires
08-15-2000 17:03:00 <DIR> HR
10-24-1999 01:29:00 4368384 IMG00022.PCD
05-18-2001 07:52:00 <DIR> jacubowsky
10-12-2000 10:55:00 <DIR> JFalvey
03-28-2001 14:38:00 <DIR> johnci
07-14-2000 08:59:00 <DIR> Karin
09-07-2000 17:48:00 <DIR> Kjung
09-28-2000 08:59:00 <DIR> LarryE
08-17-2000 18:06:00 <DIR> Larson
09-12-2000 17:22:00 <DIR> marion
08-09-2000 12:30:00 <DIR> ms25
11-16-2000 15:58:00 <DIR> MS25Brochure
03-29-2000 12:07:00 <DIR> MShistory
09-05-2000 10:35:00 <DIR> Neils
08-02-2000 18:25:00 <DIR> NLM
09-06-2000 15:04:00 <DIR> PageOne
06-27-2000 18:00:00 <DIR> pccomputing
05-09-2001 13:27:00 <DIR> pictures
07-21-2000 16:23:00 <DIR> pranks
08-22-2000 10:36:00 <DIR> Sean
08-10-2000 13:54:00 <DIR> SLeong
09-07-2000 17:46:00 <DIR> svr
07-21-2000 07:22:00 <JUNCTION> a_junction_sample
10-23-2000 13:27:00 <JUNCTION> b_junction_sample -> foo
06-15-2000 07:37:00 <JUNCTION> c_junction_sample -> bar too
07-14-2000 13:35:00 2094926 canprankdesk.tif
07-21-2000 13:19:00 95077 Jon Kauffman Enjoys the Good Life.jpg
07-21-2000 13:19:00 52275 Name Plate.jpg
07-14-2000 13:38:00 2250540 Valentineoffprank-HiRes.jpg

View file

@ -0,0 +1,189 @@
ftp> open cr.yp.to
Connected to cr.yp.to.
220 Features: a p .
Name (cr.yp.to:cyp):
230 Hi. No need to log in; I'm an anonymous ftp server.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls
200 Okay.
150 Making transfer connection...
+i0.307427,m979205905,/, tmp
+i0.631874,m951789705,/, 1998-100
+i0.236492,m977690646,r,s1172, mirrors.html
+i0.718174,m951789707,/, 1999-275
+i0.236496,m957763516,r,s933, 1999-275.html
+i0.236247,m957763626,r,s322, 1998-401.html
+i0.689416,m951789707,/, 1998-401
+i0.714380,m951789705,/, 1997-275
+i0.236426,m957763705,r,s277, 1998-515.html
+i0.236324,m957764203,r,s325, 2000-436.html
+i0.553153,m977554031,/, checkpwd
+i0.73117,m1025804866,/, bib
+i0.2012,m951789707,/, 1999-541
+i0.134494,m988426955,/, 2001-260
+i0.457327,m1019068075,/, 2002-501
+i0.11567,m991428977,/, 1995-514
+i0.716165,m951789705,/, 1999-180
+i0.236327,m991363463,r,s475, 2000-515.html
+i0.687522,m951789707,/, 1998-515
+i0.412995,m951789707,/, 2000-515
+i0.213334,m958117573,/, zpfft
+i0.295901,m1004187614,/, psibound
+i0.236429,m951789711,r,s398, anonftpd.html
+i0.326793,m1014690862,/, nistp224
+i0.587605,m997428440,/, cdb
+i0.516884,m1020211107,/, talks
+i0.255382,m977607275,/, ftpparse
+i0.103809,m947569810,/, clockspeed
+i0.236433,m951789712,r,s1350, clockspeed.html
+i0.530322,m1013028754,/, slashdoc
+i0.10002,m1023465640,/, export
+i0.105740,m995334516,/, daemontools
+i0.236425,m994972628,r,s2187, daemontools.html
+i0.236437,m999204676,r,s175, data.html
+i0.236435,m1009503157,r,s1901, crypto.html
+i0.236430,m1005435923,r,s739, arith.html
+i0.236297,m1007092089,r,s2733, cdb.html
+i0.236475,m1005436262,r,s344, floatasm.html
+i0.126821,m977433956,/, djbfft
+i0.236440,m951789712,r,s1319, djbfft.html
+i0.149876,m963163007,/, dnscache
+i0.236441,m962665064,r,s4016, dnscache.html
+i0.674064,m994734982,/, docs
+i0.236442,m951789712,r,s293, docs.html
+i0.236443,m951789712,r,s952, dot-forward.html
+i0.76895,m947569811,/, etc-mta
+i0.236444,m951789712,r,s3174, etc-mta.html
+i0.236445,m951789712,r,s2990, ezmlm.html
+i0.142082,m977433956,/, ftp
+i0.78826,m951789709,/, im
+i0.236446,m951789712,r,s1823, fastforward.html
+i0.236447,m951789712,r,s1707, ftp.html
+i0.21212,m981944230,/, freebugtraq
+i0.117314,m1022981965,/, hardware
+i0.236326,m991364255,r,s610, 1995-514.html
+i0.63463,m977433957,/, hash127
+i0.236450,m958703342,r,s4835, hash127.html
+i0.236451,m951789712,r,s1515, im.html
+i0.82651,m1013546406,/, immhf
+i0.236299,m988235329,r,s2902, immhf.html
+i0.147915,m980402316,/, lib
+i0.591514,m991784750,/, libtai
+i0.236454,m963255256,r,s2120, libtai.html
+i0.236427,m1006883560,r,s14460, qmail.html
+i0.236452,m999204683,r,s2153, mail.html
+i0.236457,m951789712,r,s108, maildir.html
+i0.71192,m951789710,/, maildisasters
+i0.236458,m951789712,r,s873, maildisasters.html
+i0.236459,m951789712,r,s1688, mess822.html
+i0.13517,m1014605247,/, mirror
+i0.236431,m1009400552,r,s581, ntheory.html
+i0.629891,m1023118587,/, papers
+i0.176720,m1021999815,/, postpropter
+i0.67332,m947569812,/, postings
+i0.101902,m947569812,/, primegen
+i0.236453,m999204693,r,s415, precompiled.html
+i0.236463,m951789712,r,s1121, primegen.html
+i0.574160,m1020562675,/, proto
+i0.236464,m951789712,r,s452, proto.html
+i0.113471,m994717073,/, publicfile
+i0.236295,m1007092757,r,s5651, publicfile.html
+i0.236455,m999204697,r,s409, qlist.html
+i0.15552,m1017725145,/, qmail
+i0.236292,m1012629148,r,s7549, lists.html
+i0.236468,m951789712,r,s1166, qmailanalog.html
+i0.236456,m999204699,r,s1434, qmsmac.html
+i0.236470,m952925886,r,s465, rblsmtpd.html
+i0.236471,m951789712,r,s1225, rights.html
+i0.691333,m947569813,/, sarcasm
+i0.236465,m1000434854,r,s1058, unix.html
+i0.236472,m951789713,r,s1568, serialmail.html
+i0.236473,m970514024,r,s840, sigs.html
+i0.80743,m1021999808,/, smtp
+i0.236300,m988300727,r,s1723, smtp.html
+i0.693264,m977433963,/, software
+i0.236476,m951789713,r,s3671, softwarelaw.html
+i0.710487,m947569813,/, sortedsums
+i0.236477,m951789713,r,s2735, sortedsums.html
+i0.23149,m1014689198,/, speed
+i0.236478,m962664017,r,s572, surveydns.html
+i0.589555,m1002157171,/, surveys
+i0.236278,m1002156396,r,s3503, surveys.html
+i0.96135,m973835888,/, syncookies
+i0.236479,m1012529017,r,s7918, syncookies.html
+i0.236460,m999204703,r,s1115, tcpcontrol.html
+i0.236461,m1016453307,r,s589, tcpip.html
+i0.236483,m951789713,r,s906, thoughts.html
+i0.136514,m996502689,/, threecubes
+i0.236462,m1000430758,r,s525, time.html
+i0.121107,m1022041265,/, ucspi-tcp
+i0.236484,m1011915691,r,s4086, ucspi-tcp.html
+i0.236285,m999204710,r,s732, web.html
+i0.236323,m1025804868,/, www
+i0.236467,m1000430768,r,s2717, y2k.html
+i0.94216,m981624489,/, dnsroot
+i0.236280,m988005697,r,s2745, 2001-260.html
+i0.236489,m951789713,r,s291, zeroseek.html
+i0.90373,m951789713,/, zmodexp
+i0.236490,m958703347,r,s1513, zmodexp.html
+i0.65452,m965092134,/, zmult
+i0.236491,m965093093,r,s669, zmult.html
+i0.236432,m977552387,r,s1097, checkpwd.html
+i0.236480,m1009824436,r,s2077, focus.html
+i0.236493,m964048291,r,s3842, im2000.html
+i0.5981,m1025804863,/, slashcommand
+i0.192219,m1025804864,/, slashpackage
+i0.236277,m995235879,r,s602, slashpackage.html
+i0.236302,m1020384933,r,s23874, talks.html
+i0.236495,m957763499,r,s566, 1997-275.html
+i0.236494,m957763864,r,s313, 1998-100.html
+i0.543361,m951789707,/, 2000-436
+i0.236424,m957764246,r,s660, 1997-494.html
+i0.236428,m957764441,r,s730, 1999-541.html
+i0.236497,m968828938,r,s2367, psibound.html
+i0.236500,m961639740,r,s1866, smallfactors.html
+i0.413016,m960514519,/, smallfactors
+i0.75096,m962492119,/, conferences
+i0.557013,m1022046749,/, djbdns
+i0.236282,m995342458,r,s2712, djbdns.html
+i0.236502,m963796539,r,s216, zpfft.html
+i0.537820,m966797797,/, fastnewton
+i0.236503,m966797851,r,s333, fastnewton.html
+i0.510806,m967833231,/, patents
+i0.236448,m977607617,r,s1748, ftpparse.html
+i0.236281,m1005436670,r,s3261, slash.html
+i0.236279,m979753810,r,s2663, slashdoc.html
+i0.236283,m1016442275,r,s2344, dnsroot.html
+i0.236284,m1009400580,r,s3238, software.html
+i0.236287,m1000434873,r,s3481, compatibility.html
+i0.236291,m1020223834,r,s5525, distributors.html
+i0.236293,m983072943,r,s212, freebugtraq.html
+i0.236294,m1017547190,r,s806, hardware.html
+i0.236296,m986022918,r,s121, securesoftware.html
+i0.236301,m1022035196,r,s10950, conferences.html
+i0.378623,m1007142710,/, 2001-275
+i0.236303,m991095307,r,s459, rwb100.html
+i0.236325,m1002087642,r,s863, nistp224.html
+i0.236436,m996502546,r,s778, threecubes.html
+i0.236298,m1023118336,r,s27125, papers.html
+i0.236439,m1006311069,r,s379, bib.html
+i0.236438,m1007142093,r,s3791, 2001-275.html
+i0.236474,m1002046139,r,s169, dh224.html
+i0.236434,m1016258736,r,s1126, courses.html
+i0.236466,m999469348,r,s355, slashcommand.html
+i0.236449,m1017264022,r,s1199, patents.html
+i0.236469,m1005247635,r,s640, mailcopyright.html
+i0.236286,m1022974070,r,s1257, djb.html
+i0.236481,m1010383954,r,s301, 2002-501.html
+i0.236482,m1020220905,r,s1655, export.html
+i0.236276,m1016966459,r,s6446, index.html
+i0.236485,m1023740653, donations.html
+i0.236486,m1016258948,r,s570, 2005-590.html
+i0.236487,m1016258749,r,s800, 2004-494.html
+i0.236488,m1023740407, thanks.html
+i0.236498,m1022974139,r,s4459, positions.html
+i0.236499,m1022972131,r,s466, contact.html
226 Success.
ftp> close
ftp>

View file

@ -0,0 +1,174 @@
01-11-2001 10:38:25 <DIR> tmp
02-29-2000 03:01:45 <DIR> 1998-100
12-24-2000 21:44:06 1172 mirrors.html
02-29-2000 03:01:47 <DIR> 1999-275
05-08-2000 07:25:16 933 1999-275.html
05-08-2000 07:27:06 322 1998-401.html
02-29-2000 03:01:47 <DIR> 1998-401
02-29-2000 03:01:45 <DIR> 1997-275
05-08-2000 07:28:25 277 1998-515.html
05-08-2000 07:36:43 325 2000-436.html
12-23-2000 07:47:11 <DIR> checkpwd
07-04-2002 19:47:46 <DIR> bib
02-29-2000 03:01:47 <DIR> 1999-541
04-28-2001 05:02:35 <DIR> 2001-260
04-17-2002 20:27:55 <DIR> 2002-501
06-01-2001 22:56:17 <DIR> 1995-514
02-29-2000 03:01:45 <DIR> 1999-180
06-01-2001 04:44:23 475 2000-515.html
02-29-2000 03:01:47 <DIR> 1998-515
02-29-2000 03:01:47 <DIR> 2000-515
05-12-2000 09:46:13 <DIR> zpfft
10-27-2001 15:00:14 <DIR> psibound
02-29-2000 03:01:51 398 anonftpd.html
02-26-2002 03:34:22 <DIR> nistp224
08-10-2001 09:27:20 <DIR> cdb
05-01-2002 01:58:27 <DIR> talks
12-23-2000 22:34:35 <DIR> ftpparse
01-11-2000 06:50:10 <DIR> clockspeed
02-29-2000 03:01:52 1350 clockspeed.html
02-06-2002 21:52:34 <DIR> slashdoc
06-07-2002 18:00:40 <DIR> export
07-17-2001 03:48:36 <DIR> daemontools
07-12-2001 23:17:08 2187 daemontools.html
08-30-2001 22:51:16 175 data.html
12-28-2001 02:32:37 1901 crypto.html
11-11-2001 00:45:23 739 arith.html
11-30-2001 04:48:09 2733 cdb.html
11-11-2001 00:51:02 344 floatasm.html
12-21-2000 22:25:56 <DIR> djbfft
02-29-2000 03:01:52 1319 djbfft.html
07-09-2000 19:16:47 <DIR> dnscache
07-04-2000 00:57:44 4016 dnscache.html
07-10-2001 05:16:22 <DIR> docs
02-29-2000 03:01:52 293 docs.html
02-29-2000 03:01:52 952 dot-forward.html
01-11-2000 06:50:11 <DIR> etc-mta
02-29-2000 03:01:52 3174 etc-mta.html
02-29-2000 03:01:52 2990 ezmlm.html
12-21-2000 22:25:56 <DIR> ftp
02-29-2000 03:01:49 <DIR> im
02-29-2000 03:01:52 1823 fastforward.html
02-29-2000 03:01:52 1707 ftp.html
02-12-2001 03:17:10 <DIR> freebugtraq
06-02-2002 03:39:25 <DIR> hardware
06-01-2001 04:57:35 610 1995-514.html
12-21-2000 22:25:57 <DIR> hash127
05-19-2000 04:29:02 4835 hash127.html
02-29-2000 03:01:52 1515 im.html
02-12-2002 21:40:06 <DIR> immhf
04-25-2001 23:48:49 2902 immhf.html
01-25-2001 06:58:36 <DIR> lib
06-06-2001 01:45:50 <DIR> libtai
07-10-2000 20:54:16 2120 libtai.html
11-27-2001 18:52:40 14460 qmail.html
08-30-2001 22:51:23 2153 mail.html
02-29-2000 03:01:52 108 maildir.html
02-29-2000 03:01:50 <DIR> maildisasters
02-29-2000 03:01:52 873 maildisasters.html
02-29-2000 03:01:52 1688 mess822.html
02-25-2002 03:47:27 <DIR> mirror
12-26-2001 22:02:32 581 ntheory.html
06-03-2002 17:36:27 <DIR> papers
05-21-2002 18:50:15 <DIR> postpropter
01-11-2000 06:50:12 <DIR> postings
01-11-2000 06:50:12 <DIR> primegen
08-30-2001 22:51:33 415 precompiled.html
02-29-2000 03:01:52 1121 primegen.html
05-05-2002 03:37:55 <DIR> proto
02-29-2000 03:01:52 452 proto.html
07-10-2001 00:17:53 <DIR> publicfile
11-30-2001 04:59:17 5651 publicfile.html
08-30-2001 22:51:37 409 qlist.html
04-02-2002 06:25:45 <DIR> qmail
02-02-2002 06:52:28 7549 lists.html
02-29-2000 03:01:52 1166 qmailanalog.html
08-30-2001 22:51:39 1434 qmsmac.html
03-13-2000 06:38:06 465 rblsmtpd.html
02-29-2000 03:01:52 1225 rights.html
01-11-2000 06:50:13 <DIR> sarcasm
09-14-2001 04:34:14 1058 unix.html
02-29-2000 03:01:53 1568 serialmail.html
10-02-2000 21:13:44 840 sigs.html
05-21-2002 18:50:08 <DIR> smtp
04-26-2001 17:58:47 1723 smtp.html
12-21-2000 22:26:03 <DIR> software
02-29-2000 03:01:53 3671 softwarelaw.html
01-11-2000 06:50:13 <DIR> sortedsums
02-29-2000 03:01:53 2735 sortedsums.html
02-26-2002 03:06:38 <DIR> speed
07-04-2000 00:40:17 572 surveydns.html
10-04-2001 02:59:31 <DIR> surveys
10-04-2001 02:46:36 3503 surveys.html
11-10-2000 06:58:08 <DIR> syncookies
02-01-2002 03:03:37 7918 syncookies.html
08-30-2001 22:51:43 1115 tcpcontrol.html
03-18-2002 13:08:27 589 tcpip.html
02-29-2000 03:01:53 906 thoughts.html
07-30-2001 16:18:09 <DIR> threecubes
09-14-2001 03:25:58 525 time.html
05-22-2002 06:21:05 <DIR> ucspi-tcp
01-25-2002 00:41:31 4086 ucspi-tcp.html
08-30-2001 22:51:50 732 web.html
07-04-2002 19:47:48 <DIR> www
09-14-2001 03:26:08 2717 y2k.html
02-08-2001 10:28:09 <DIR> dnsroot
04-23-2001 08:01:37 2745 2001-260.html
02-29-2000 03:01:53 291 zeroseek.html
02-29-2000 03:01:53 <DIR> zmodexp
05-19-2000 04:29:07 1513 zmodexp.html
08-01-2000 03:08:54 <DIR> zmult
08-01-2000 03:24:53 669 zmult.html
12-23-2000 07:19:47 1097 checkpwd.html
12-31-2001 19:47:16 2077 focus.html
07-20-2000 01:11:31 3842 im2000.html
07-04-2002 19:47:43 <DIR> slashcommand
07-04-2002 19:47:44 <DIR> slashpackage
07-16-2001 00:24:39 602 slashpackage.html
05-03-2002 02:15:33 23874 talks.html
05-08-2000 07:24:59 566 1997-275.html
05-08-2000 07:31:04 313 1998-100.html
02-29-2000 03:01:47 <DIR> 2000-436
05-08-2000 07:37:26 660 1997-494.html
05-08-2000 07:40:41 730 1999-541.html
09-13-2000 09:08:58 2367 psibound.html
06-22-2000 04:09:00 1866 smallfactors.html
06-09-2000 03:35:19 <DIR> smallfactors
07-02-2000 00:55:19 <DIR> conferences
05-22-2002 07:52:29 <DIR> djbdns
07-17-2001 06:00:58 2712 djbdns.html
07-17-2000 03:15:39 216 zpfft.html
08-20-2000 20:56:37 <DIR> fastnewton
08-20-2000 20:57:31 333 fastnewton.html
09-01-2000 20:33:51 <DIR> patents
12-23-2000 22:40:17 1748 ftpparse.html
11-11-2001 00:57:50 3261 slash.html
01-17-2001 18:50:10 2663 slashdoc.html
03-18-2002 10:04:35 2344 dnsroot.html
12-26-2001 22:03:00 3238 software.html
09-14-2001 04:34:33 3481 compatibility.html
05-01-2002 05:30:34 5525 distributors.html
02-25-2001 04:49:03 212 freebugtraq.html
03-31-2002 04:59:50 806 hardware.html
03-31-2001 08:15:18 121 securesoftware.html
05-22-2002 04:39:56 10950 conferences.html
11-30-2001 18:51:50 <DIR> 2001-275
05-29-2001 02:15:07 459 rwb100.html
10-03-2001 07:40:42 863 nistp224.html
07-30-2001 16:15:46 778 threecubes.html
06-03-2002 17:32:16 27125 papers.html
11-21-2001 03:51:09 379 bib.html
11-30-2001 18:41:33 3791 2001-275.html
10-02-2001 20:08:59 169 dh224.html
03-16-2002 07:05:36 1126 courses.html
09-03-2001 00:22:28 355 slashcommand.html
03-27-2002 22:20:22 1199 patents.html
11-08-2001 20:27:15 640 mailcopyright.html
06-02-2002 01:27:50 1257 djb.html
01-07-2002 07:12:34 301 2002-501.html
05-01-2002 04:41:45 1655 export.html
03-24-2002 11:40:59 6446 index.html
03-16-2002 07:09:08 570 2005-590.html
03-16-2002 07:05:49 800 2004-494.html
06-02-2002 01:28:59 4459 positions.html
06-02-2002 00:55:31 466 contact.html

View file

@ -0,0 +1,19 @@
220 server IBM TCP/IP for OS/2 - FTP Server ver 23:04:36 on Jan 15 1997
This listing is just a guess because I couldn't find an FTP server that
LISTs like this. This guess is based on comments in Perl mirror project.
I'm particularly unsure of the contents of cols 19-34.
1 2 3 4 5 6
0123456789012345678901234567890123456789012345678901234567890123456789
----- size -------| ?????????????? MM-DD-YY| HH:MM| nnnnnnnnn....
0 DIR 04-11-95 16:26 .
0 DIR 04-11-95 16:26 ..
0 DIR 04-11-95 16:26 ADDRESS
612 A 07-28-95 16:45 air_tra1.bag
195 A 08-09-95 10:23 Alfa1.bag
0 DIR 04-11-95 16:26 ATTACH
372 A 08-09-95 10:26 Aussie_1.bag
310992 06-28-94 09:56 INSTALL.EXE
12345 H 10-19-00 15:10 ADOE ADIR MOZILLA.FAKEOUT

View file

@ -0,0 +1,13 @@
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
04-11-1995 16:26:00 <DIR> .
04-11-1995 16:26:00 <DIR> ..
04-11-1995 16:26:00 <DIR> ADDRESS
07-28-1995 16:45:00 612 air_tra1.bag
08-09-1995 10:23:00 195 Alfa1.bag
04-11-1995 16:26:00 <DIR> ATTACH
08-09-1995 10:26:00 372 Aussie_1.bag
06-28-1994 09:56:00 310992 INSTALL.EXE
10-19-2000 15:10:00 12345 ADOE ADIR MOZILLA.FAKEOUT

View file

@ -0,0 +1,23 @@
README 763 Information about this server
bin/ -
etc/ =
ls-lR 0
ls-lR.Z 3
pub/ = Public area
usr/ -
morgan 14 -> ../real/morgan
TIMIT.mostlikely.Z
79215
README 763 Feb 3 18:21 Information about this server
bin/ - Apr 28 1994
etc/ = 11 Jul 21:04
ls-lR 0 6 Aug 17:14
ls-lR.Z 3 05 Sep 1994
pub/ = Jul 11 21:04 Public area
usr/ - Sep 7 09:39
morgan 14 Apr 18 9:39 -> ../real/morgan
TIMIT.mostlikely.Z
79215 Jan 4 6:45
*** CAUTION while editing this sample LISTing -
*** Lines contain trailing whitespace and/or '\r's

View file

@ -0,0 +1,22 @@
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
00-00-0000 00:00:00 763 README
00-00-0000 00:00:00 <DIR> bin
00-00-0000 00:00:00 <DIR> etc
00-00-0000 00:00:00 0 ls-lR
00-00-0000 00:00:00 3 ls-lR.Z
00-00-0000 00:00:00 <DIR> pub
00-00-0000 00:00:00 <DIR> usr
00-00-0000 00:00:00 <JUNCTION> morgan -> ../real/morgan
00-00-0000 00:00:00 79215 TIMIT.mostlikely.Z
02-03-2002 18:21:00 763 README
04-28-1994 00:00:00 <DIR> bin
07-11-2002 21:04:00 <DIR> etc
08-06-2001 17:14:00 0 ls-lR
09-05-1994 00:00:00 3 ls-lR.Z
07-11-2002 21:04:00 <DIR> pub
09-07-2001 09:39:00 <DIR> usr
04-18-2002 09:39:00 <JUNCTION> morgan -> ../real/morgan
01-04-2002 06:45:00 79215 TIMIT.mostlikely.Z

View file

@ -0,0 +1,28 @@
Testcases for the following:
- VMS (MultiNet, UCX, and CMU) LIST format (including multi-line format)
- IBM VM/CMS, VM/ESA LIST format (two known variants)
- Windows NT's default "DOS-dirstyle"
- OS/2 basic server format LIST format
- SuperTCP FTP Server
- NetManage Chameleon (NEWT)
- EPLF (Easily Parsable List Format)
- '/bin/dls' (two known variants, plus multi-line) LIST format
- '/bin/ls -l' and all variants (even if they are not SYST UNIX)
including
- Hellsoft FTP for NetWare (non-unix perm-bits)
- Hethmon Brothers FTP for OS/2 (all '-' perm bits)
- NetPresenz (SYST is "MACOS")
- "NETWARE" (Hellsoft-style perms, no linkcount, no UID/GID)
- OpenBSD FTPD (numeric UID/GID)
- Open Group's FTP servers (no GID)
- Novonyx [Netscape/Novell] (fields not in columns)
- wuFTPd and other BSD-based ftpd that exec "ls -l"
- Windows NT server (internal "ls -l" compatible)
- Netmanage ProFTPD for Win32 (internal "ls -l" compatible)
- SurgeFTPd for Win32 (internal "ls -l" compatible)
- WarFTPd for Win32 (internal "ls -l" compatible)
- WebStarFTP for MacOS (internal "ls -l" compatible)
- MurkWorks FTP for NetWare (internal "ls -l" compatible)
- NcFTPd for Unix (internal "ls -l" compatible).

View file

@ -0,0 +1,25 @@
ftp> open pandora.anglistik.uni-mainz.de
220 pandora FTP Server for NW 3.1x, 4.xx (v1.10), (c) 1994 HellSoft.
Name (pandora.anglistik.uni-mainz.de:cyp):
331 Password required.
230-User Logged.
230 Home Directory: /SYS/USER/FTP
ftp> ls
200 Command Accepted.
150 Opening ASCII data connection.
d[RWCEMFA] 1 cyp 512 Jul 01 11:49 htdocs
d[RWCEMFA] 1 cyp 512 Jul 02 08:56 config
d[RWCEMFA] 1 cyp 512 Jun 20 11:23 other
d[RWCEMFA] 1 cyp 512 Jun 20 11:23 mail
d[RWCEMFA] 1 cyp 512 Jun 20 14:35 news
d[RWCEMFA] 1 cyp 512 Jun 30 08:48 download
-[RWCEMFA] 1 *unknown 13312 May 27 1997 19calit.doc
-[RWCEMFA] 1 *unknown 237 Feb 21 1997 forfile.bat
-[RWCEMFA] 1 *unknown 1401 Mar 03 1997 intertex.txt
d[RWCEMFA] 1 cyp 512 May 15 08:55 d1
d[RWCEMFA] 1 cyp 512 May 06 10:57 drivers
d[RWCEMFA] 1 cyp 512 Mar 28 12:05 --moved-
226 Transfer complete.
ftp> close
221 Goodbye.
ftp>

View file

@ -0,0 +1,16 @@
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
07-01-2002 11:49:00 <DIR> htdocs
07-02-2002 08:56:00 <DIR> config
06-20-2002 11:23:00 <DIR> other
06-20-2002 11:23:00 <DIR> mail
06-20-2002 14:35:00 <DIR> news
06-30-2002 08:48:00 <DIR> download
05-27-1997 00:00:00 13312 19calit.doc
02-21-1997 00:00:00 237 forfile.bat
03-03-1997 00:00:00 1401 intertex.txt
05-15-2002 08:55:00 <DIR> d1
05-06-2002 10:57:00 <DIR> drivers
03-28-2002 12:05:00 <DIR> --moved-

View file

@ -0,0 +1,31 @@
ftp> open gean5.pfmb.uni-mb.si
Connected to gean5.pfmb.uni-mb.si.
220 NetPresenz v4.1 (Unregistered) awaits your command.
Name (gean5.pfmb.uni-mb.si:cyp):
331 Guest log in, send Email address (user@host) as password.
230-This file must be in the Startup Messages folder in either the same
folder as NetPresenz or in the NetPresenz Preferences folder in the
Preferences folder, and will be displayed to guests user when they log
in. Guest users log in by using the username "ftp" or "anonymous".
230 Anonymous login to 1 volumes. Access restrictions apply. "/Eng Dept web pages/MariborEnglishClub".
Remote system type is MACOS.
ftp> ls
200 PORT command successful.
150 ASCII transfer started.
-------r-- 0 2166 2166 Mar 22 09:21 default.htm
-------r-- 0 16504 16504 Mar 21 14:32 FAQs.htm
drwxr-xr-x folder 5 Mar 22 10:06 FAQs_files
-------r-- 0 250 250 Mar 22 09:22 filelist.xml
-------r-- 0 1575 1575 Mar 21 14:22 image001.gif
-------r-- 0 631827 631827 Mar 21 14:22 image002.jpg
-------r-- 0 34318 34318 Mar 21 14:22 image003.jpg
-------r-- 0 9121 9121 Mar 22 09:30 MariborEnglishClubHomepage.htm
-------r-- 0 6710 6710 Mar 21 14:30 Photos.htm
drwxr-xr-x folder 5 Mar 22 10:06 Photos_files
-------r-- 0 5995 5995 Mar 22 09:23 TOCFrame.htm
-------r-- 0 7226 7226 Mar 21 14:27 Upcoming Events.htm
drwxr-xr-x folder 3 Mar 22 10:06 Upcoming Events_files
226 Transfer complete.
ftp>ftp> close
221 Nice chatting with you.
ftp>

View file

@ -0,0 +1,17 @@
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
03-22-2002 09:21:00 2166 default.htm
03-21-2002 14:32:00 16504 FAQs.htm
03-22-2002 10:06:00 <DIR> FAQs_files
03-22-2002 09:22:00 250 filelist.xml
03-21-2002 14:22:00 1575 image001.gif
03-21-2002 14:22:00 631827 image002.jpg
03-21-2002 14:22:00 34318 image003.jpg
03-22-2002 09:30:00 9121 MariborEnglishClubHomepage.htm
03-21-2002 14:30:00 6710 Photos.htm
03-22-2002 10:06:00 <DIR> Photos_files
03-22-2002 09:23:00 5995 TOCFrame.htm
03-21-2002 14:27:00 7226 Upcoming Events.htm
03-22-2002 10:06:00 <DIR> Upcoming Events_files

View file

@ -0,0 +1,51 @@
ftp> open netlab2.usu.edu
Connected to netlab2.usu.edu.
220 Service Ready for new User
Name (netlab2.usu.edu:cyp):
331 Enter E-Mail id as Password
230 User anonymous Logged in Successfully
Remote system type is NETWARE.
ftp> syst
215 NETWARE Type : L8
ftp> ls
200 PORT Command OK
150 Opening data connection
total 0
- [RWCEAFMS] NFAUUser 192 Apr 27 15:21 HEADER.html
d [RWCEAFMS] jrd 512 Jul 11 03:01 allupdates
d [RWCEAFMS] jrd 512 Dec 05 2001 apps
d [RWCEAFMS] jrd 512 Oct 21 2001 bsuk00
d [RWCEAFMS] jrd 512 Oct 21 2001 bsuk2001
d [RWCEAFMS] jrd 512 Oct 21 2001 bsuk99
d [RWCEAFMS] jrd 512 Oct 21 2001 bsus2000
d [RWCEAFMS] jrd 512 Oct 21 2001 bsus2001
d [RWCEAFMS] jrd 512 Mar 27 20:23 bsus2002
d [RWCEAFMS] jrd 512 Oct 21 2001 bsus99
d [RWCEAFMS] jrd 512 Oct 21 2001 drivers
d [RWCEAFMS] jrd 512 Oct 24 2001 freebird
d [RWCEAFMS] jrd 512 Apr 30 13:56 kermit
d [RWCEAFMS] jrd 512 Oct 21 2001 macipx
d [RWCEAFMS] jrd 512 Jun 13 01:45 misc
d [RWCEAFMS] jrd 512 Oct 21 2001 netwatch
d [RWCEAFMS] jrd 512 Oct 21 2001 netwire
d [RWCEAFMS] jrd 512 Oct 21 2001 odi
d [RWCEAFMS] jrd 512 Oct 21 2001 pktdrvr
d [RWCEAFMS] jrd 512 Mar 02 20:23 rfc
d [RWCEAFMS] jrd 512 Oct 30 2001 UnixWare
d [RWCEAFMS] jrd 512 Oct 21 2001 updates
- [RWCEAFMS] jrd 666258 Oct 30 1992 ENCAPS10.PS
- [RWCEAFMS] jrd 25085 Oct 28 1992 ENCAPS10.TXT
- [RWCEAFMS] jrd 611989 Jan 13 1993 ENCAPS11.PS
- [RWCEAFMS] jrd 27134 Jan 12 1993 ENCAPS11.TXT
- [RWCEAFMS] jrd 372 Jan 13 1993 README.TXT
226 Transfer Complete
ftp> site help
214-Only DOS and LONG site commands are supported for Anonymous Users
DOS :
The DOS command shows the file/directory permissions in DOS format.
LONG :
The LONG command shows the file/directory permissions in LONG format.
214 End of Help
ftp> close
221 Closing Session
ftp>

View file

@ -0,0 +1,31 @@
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
04-27-2002 15:21:00 192 HEADER.html
07-11-2002 03:01:00 <DIR> allupdates
12-05-2001 00:00:00 <DIR> apps
10-21-2001 00:00:00 <DIR> bsuk00
10-21-2001 00:00:00 <DIR> bsuk2001
10-21-2001 00:00:00 <DIR> bsuk99
10-21-2001 00:00:00 <DIR> bsus2000
10-21-2001 00:00:00 <DIR> bsus2001
03-27-2002 20:23:00 <DIR> bsus2002
10-21-2001 00:00:00 <DIR> bsus99
10-21-2001 00:00:00 <DIR> drivers
10-24-2001 00:00:00 <DIR> freebird
04-30-2002 13:56:00 <DIR> kermit
10-21-2001 00:00:00 <DIR> macipx
06-13-2002 01:45:00 <DIR> misc
10-21-2001 00:00:00 <DIR> netwatch
10-21-2001 00:00:00 <DIR> netwire
10-21-2001 00:00:00 <DIR> odi
10-21-2001 00:00:00 <DIR> pktdrvr
03-02-2002 20:23:00 <DIR> rfc
10-30-2001 00:00:00 <DIR> UnixWare
10-21-2001 00:00:00 <DIR> updates
10-30-1992 00:00:00 666258 ENCAPS10.PS
10-28-1992 00:00:00 25085 ENCAPS10.TXT
01-13-1993 00:00:00 611989 ENCAPS11.PS
01-12-1993 00:00:00 27134 ENCAPS11.TXT
01-13-1993 00:00:00 372 README.TXT

View file

@ -0,0 +1,92 @@
ftp> open pandora.anglistik.uni-mainz.de
220- Novonyx FTP Server for NetWare, v0.51 (9-16-98)
220 Service Ready
Name (pandora.anglistik.uni-mainz.de:cyp):
331 User name okay, need password
230 User logged in, proceed
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> cd login
250 Directory successfully changed
ftp> ls
200 PORT Command OK
150 File status OK, about to open data connection
total 123
-rw-rw-rw- 1 root sysadmin 25775 Sep 29 19:45 NOD$UPD.BAT
-r--r--r-- 1 root sysadmin 2860 Feb 6 22:03 AX_RUN.OVL
-r--r--r-- 1 root sysadmin 4965 Feb 6 22:03 B5DV_AIO.OVL
-r--r--r-- 1 root sysadmin 7843 Feb 6 22:03 B5DV_RUN.OVL
-r--r--r-- 1 root sysadmin 4965 Feb 6 22:03 B5ET_AIO.OVL
-r--r--r-- 1 root sysadmin 5589 Feb 6 22:03 B5ET_RUN.OVL
-r--r--r-- 1 root sysadmin 4965 Feb 6 22:03 B5KC_AIO.OVL
-r--r--r-- 1 root sysadmin 5042 Feb 6 22:03 B5KC_RUN.OVL
-r--r--r-- 1 root sysadmin 4965 Feb 6 22:03 BIG5_AIO.OVL
-r--r--r-- 1 root sysadmin 3710 Feb 6 22:03 BIG5_RUN.OVL
-r--r--r-- 1 root sysadmin 4965 Feb 6 22:03 CMPQ_AIO.OVL
-r--r--r-- 1 root sysadmin 2815 Feb 6 22:03 CMPQ_RUN.OVL
-r-xr-xr-x 1 root sysadmin 210009 Feb 6 22:03 CX.EXE
-r--r--r-- 1 root sysadmin 4965 Feb 6 22:03 DOSV_AIO.OVL
-r--r--r-- 1 root sysadmin 3825 Feb 6 22:03 DOSV_RUN.OVL
-r--r--r-- 1 root sysadmin 16264 Feb 6 22:03 ETHER.RPL
-r--r--r-- 1 root sysadmin 12133 Feb 6 22:03 F1ETH.RPL
-r--r--r-- 1 root sysadmin 5141 Feb 6 22:03 FMR_AIO.OVL
-r--r--r-- 1 root sysadmin 4747 Feb 6 22:03 FMR_RUN.OVL
-r--r--r-- 1 root sysadmin 4965 Feb 6 22:03 GBCD_AIO.OVL
-r--r--r-- 1 root sysadmin 3857 Feb 6 22:03 GBCD_RUN.OVL
-r--r--r-- 1 root sysadmin 4965 Feb 6 22:03 GBET_AIO.OVL
-r--r--r-- 1 root sysadmin 5545 Feb 6 22:03 GBET_RUN.OVL
-r--r--r-- 1 root sysadmin 4965 Feb 6 22:03 GBLX_AIO.OVL
-r--r--r-- 1 root sysadmin 3913 Feb 6 22:03 GBLX_RUN.OVL
-r--r--r-- 1 root sysadmin 4965 Feb 6 22:03 GBPD_AIO.OVL
-r--r--r-- 1 root sysadmin 8019 Feb 6 22:03 GBPD_RUN.OVL
-r--r--r-- 1 root sysadmin 4965 Feb 6 22:03 GBSP_AIO.OVL
-r--r--r-- 1 root sysadmin 8141 Feb 6 22:03 GBSP_RUN.OVL
-r--r--r-- 1 root sysadmin 4965 Feb 6 22:03 GBTW_AIO.OVL
-r--r--r-- 1 root sysadmin 4152 Feb 6 22:03 GBTW_RUN.OVL
-r--r--r-- 1 root sysadmin 4965 Feb 6 22:03 GBUC_AIO.OVL
-r--r--r-- 1 root sysadmin 4033 Feb 6 22:03 GBUC_RUN.OVL
-r--r--r-- 1 root sysadmin 4965 Feb 6 22:03 GBWM_AIO.OVL
-r--r--r-- 1 root sysadmin 3710 Feb 6 22:03 GBWM_RUN.OVL
-r--r--r-- 1 root sysadmin 4965 Feb 6 22:03 GBXJ_AIO.OVL
-r--r--r-- 1 root sysadmin 3848 Feb 6 22:03 GBXJ_RUN.OVL
-r--r--r-- 1 root sysadmin 4965 Feb 6 22:03 GB_AIO.OVL
-r--r--r-- 1 root sysadmin 3710 Feb 6 22:03 GB_RUN.OVL
-r--r--r-- 1 root sysadmin 4965 Feb 6 22:03 IBM_AIO.OVL
-r--r--r-- 1 root sysadmin 2815 Feb 6 22:03 IBM_RUN.OVL
-r--r--r-- 1 root sysadmin 4965 Feb 6 22:03 J31_AIO.OVL
-r--r--r-- 1 root sysadmin 5240 Feb 6 22:03 J31_RUN.OVL
-r--r--r-- 1 root sysadmin 4965 Feb 6 22:03 KOR_AIO.OVL
-r--r--r-- 1 root sysadmin 3710 Feb 6 22:03 KOR_RUN.OVL
-r--r--r-- 1 root sysadmin 4965 Feb 6 22:03 KSC_AIO.OVL
-r--r--r-- 1 root sysadmin 3710 Feb 6 22:03 KSC_RUN.OVL
-r-xr-xr-x 1 root sysadmin 311171 Apr 4 14:19 LOGIN.EXE
-r--r--r-- 1 root sysadmin 5167 Feb 6 22:03 PC98_AIO.OVL
-r--r--r-- 1 root sysadmin 7152 Feb 6 22:03 PC98_RUN.OVL
-r--r--r-- 1 root sysadmin 10991 Feb 6 22:03 PCN2L.RPL
-r--r--r-- 1 root sysadmin 4965 Feb 6 22:03 PS55_AIO.OVL
-r--r--r-- 1 root sysadmin 3616 Feb 6 22:03 PS55_RUN.OVL
-r--r--r-- 1 root sysadmin 8074 Feb 6 22:03 RBOOT.RPL
-r--r--r-- 1 root sysadmin 9170 Feb 6 22:03 TEXTUTIL.IDX
-r--r--r-- 1 root sysadmin 18433 Feb 6 22:03 TOKEN.RPL
-r-xr-xr-x 1 root sysadmin 43549 Feb 6 22:03 TYPEMSG.EXE
-r--r--r-- 1 root sysadmin 27 Feb 6 22:03 ATTACH.BAT
-rwxrwxrwx 1 root sysadmin 439913 Feb 6 23:33 NLIST.EXE
-r--r--r-- 1 root sysadmin 307 Feb 6 22:03 MENU_X.BAT
-rwxrwxrwx 1 root sysadmin 269247 Feb 6 23:33 MAP.EXE
-r--r--r-- 1 root sysadmin 4965 Feb 6 22:03 AX_AIO.OVL
-r-xr-xr-x 1 root sysadmin 111663 Apr 16 12:20 LOGIN3X.EXE
-rw-rw-rw- 1 root sysadmin 38 Apr 18 15:19 login.nb
-r-xr-xr-x 1 root sysadmin 392528 Apr 20 04:02 NPRINTER.EXE
-r-xr-xr-x 1 root sysadmin 311171 Feb 9 16:29 LOGIN4X.EXE
-rw-rw-rw- 1 root sysadmin 2102 Feb 8 13:18 lpt$cap.bat
-rw-rw-rw- 1 root sysadmin 20614 Mar 13 13:42 nod$log.bat
-rw-rw-rw- 1 root sysadmin 20450 Mar 12 10:36 nod$log.~ba
drwxrwxrwx 1 root sysadmin 0 Mar 8 13:30 NLS
drwxrwxrwx 1 root sysadmin 0 Mar 8 13:30 OS2
drwxrwxrwx 1 root sysadmin 0 Apr 9 16:37 NOD$LOG.DRV
drwxrwxrwx 1 root sysadmin 0 Apr 9 16:36 LOCAL
drwxrwxrwx 1 root sysadmin 0 Mar 16 14:25 local.nt4
226 Requested file action okay, completed
ftp> close
221 Service closing connection, user logged out
ftp>

View file

@ -0,0 +1,78 @@
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
09-29-2001 19:45:00 25775 NOD$UPD.BAT
02-06-2002 22:03:00 2860 AX_RUN.OVL
02-06-2002 22:03:00 4965 B5DV_AIO.OVL
02-06-2002 22:03:00 7843 B5DV_RUN.OVL
02-06-2002 22:03:00 4965 B5ET_AIO.OVL
02-06-2002 22:03:00 5589 B5ET_RUN.OVL
02-06-2002 22:03:00 4965 B5KC_AIO.OVL
02-06-2002 22:03:00 5042 B5KC_RUN.OVL
02-06-2002 22:03:00 4965 BIG5_AIO.OVL
02-06-2002 22:03:00 3710 BIG5_RUN.OVL
02-06-2002 22:03:00 4965 CMPQ_AIO.OVL
02-06-2002 22:03:00 2815 CMPQ_RUN.OVL
02-06-2002 22:03:00 210009 CX.EXE
02-06-2002 22:03:00 4965 DOSV_AIO.OVL
02-06-2002 22:03:00 3825 DOSV_RUN.OVL
02-06-2002 22:03:00 16264 ETHER.RPL
02-06-2002 22:03:00 12133 F1ETH.RPL
02-06-2002 22:03:00 5141 FMR_AIO.OVL
02-06-2002 22:03:00 4747 FMR_RUN.OVL
02-06-2002 22:03:00 4965 GBCD_AIO.OVL
02-06-2002 22:03:00 3857 GBCD_RUN.OVL
02-06-2002 22:03:00 4965 GBET_AIO.OVL
02-06-2002 22:03:00 5545 GBET_RUN.OVL
02-06-2002 22:03:00 4965 GBLX_AIO.OVL
02-06-2002 22:03:00 3913 GBLX_RUN.OVL
02-06-2002 22:03:00 4965 GBPD_AIO.OVL
02-06-2002 22:03:00 8019 GBPD_RUN.OVL
02-06-2002 22:03:00 4965 GBSP_AIO.OVL
02-06-2002 22:03:00 8141 GBSP_RUN.OVL
02-06-2002 22:03:00 4965 GBTW_AIO.OVL
02-06-2002 22:03:00 4152 GBTW_RUN.OVL
02-06-2002 22:03:00 4965 GBUC_AIO.OVL
02-06-2002 22:03:00 4033 GBUC_RUN.OVL
02-06-2002 22:03:00 4965 GBWM_AIO.OVL
02-06-2002 22:03:00 3710 GBWM_RUN.OVL
02-06-2002 22:03:00 4965 GBXJ_AIO.OVL
02-06-2002 22:03:00 3848 GBXJ_RUN.OVL
02-06-2002 22:03:00 4965 GB_AIO.OVL
02-06-2002 22:03:00 3710 GB_RUN.OVL
02-06-2002 22:03:00 4965 IBM_AIO.OVL
02-06-2002 22:03:00 2815 IBM_RUN.OVL
02-06-2002 22:03:00 4965 J31_AIO.OVL
02-06-2002 22:03:00 5240 J31_RUN.OVL
02-06-2002 22:03:00 4965 KOR_AIO.OVL
02-06-2002 22:03:00 3710 KOR_RUN.OVL
02-06-2002 22:03:00 4965 KSC_AIO.OVL
02-06-2002 22:03:00 3710 KSC_RUN.OVL
04-04-2002 14:19:00 311171 LOGIN.EXE
02-06-2002 22:03:00 5167 PC98_AIO.OVL
02-06-2002 22:03:00 7152 PC98_RUN.OVL
02-06-2002 22:03:00 10991 PCN2L.RPL
02-06-2002 22:03:00 4965 PS55_AIO.OVL
02-06-2002 22:03:00 3616 PS55_RUN.OVL
02-06-2002 22:03:00 8074 RBOOT.RPL
02-06-2002 22:03:00 9170 TEXTUTIL.IDX
02-06-2002 22:03:00 18433 TOKEN.RPL
02-06-2002 22:03:00 43549 TYPEMSG.EXE
02-06-2002 22:03:00 27 ATTACH.BAT
02-06-2002 23:33:00 439913 NLIST.EXE
02-06-2002 22:03:00 307 MENU_X.BAT
02-06-2002 23:33:00 269247 MAP.EXE
02-06-2002 22:03:00 4965 AX_AIO.OVL
04-16-2002 12:20:00 111663 LOGIN3X.EXE
04-18-2002 15:19:00 38 login.nb
04-20-2002 04:02:00 392528 NPRINTER.EXE
02-09-2002 16:29:00 311171 LOGIN4X.EXE
02-08-2002 13:18:00 2102 lpt$cap.bat
03-13-2002 13:42:00 20614 nod$log.bat
03-12-2002 10:36:00 20450 nod$log.~ba
03-08-2002 13:30:00 <DIR> NLS
03-08-2002 13:30:00 <DIR> OS2
04-09-2002 16:37:00 <DIR> NOD$LOG.DRV
04-09-2002 16:36:00 <DIR> LOCAL
03-16-2002 14:25:00 <DIR> local.nt4

View file

@ -0,0 +1,66 @@
ftp> open netwinsite.com
Connected to netwinsite.com.
220 SurgeFTP netwin1 (Version 2.1e)
Name (netwinsite.com:cyp): 331 Guest login ok, send your complete e-mail address as password.
230- Alias Real path Access
230- / /disk2/ftp read
230 User anonymous logged in.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> cd pub
250 CWD command successful now (/pub)
ftp> ls
200 PORT command successful.
150 Opening ASCII mode data connection for file list. (/pub)
drwxr-xr-x 2 jesseftp netwin 4096 Jul 7 21:37 cgimail
drwxr-xr-x 4 dnewsftp netwin 4096 May 2 17:38 dbabble
drwxr-xr-x 2 netwin netwin 4096 Jul 1 2001 dek_temp
drwxr-xr-x 2 netwin netwin 4096 Jul 1 2001 deye
drwxr-xr-x 2 jesseftp root 4096 Feb 18 17:50 dfree
drwxr-xr-x 2 netwin netwin 4096 Jul 1 2001 dgate
drwxr-xr-x 4 root root 4096 Jan 31 15:18 discontinued
drwxr-xr-x 4 dmailftp netwin 8192 Jul 7 21:28 dmail
drwxr-xr-x 4 pnftp netwin 4096 Jun 30 17:56 dmailweb
drwxr-xr-x 8 dnewsftp netwin 8192 Jul 10 1:40 dnews
drwxr-xr-x 3 netwin netwin 4096 Jul 1 2001 dnewsweb
drwxr-xr-x 3 pnftp root 4096 Sep 4 2001 dnotice
drwxr-xr-x 2 root root 4096 May 6 16:58 fengate
drwxr-xr-x 2 pnftp root 4096 May 28 19:01 ferngate
drwxr-xr-x 3 netwin netwin 4096 Jul 1 2001 jeeves
drwxr-xr-x 2 netwin netwin 4096 Jun 27 20:10 misc
drwxr-xr-x 3 pnftp bin 4096 Jul 4 21:13 netauth
drwxr-xr-x 2 pnftp bin 4096 Feb 8 1999 poppassd
drwxr-xr-x 2 jesseftp netwin 4096 Jul 9 1:39 surgeftp
drwxr-xr-x 2 surgemail root 4096 Jul 3 0:00 surgemail
drwxr-xr-x 2 surgemail root 4096 Jul 3 0:01 surgemail-enterprise
drwxr-xr-x 2 surgemail root 4096 Jul 3 0:01 surgemail-home
drwxr-xr-x 2 surgemail root 4096 Jul 3 0:01 surgemail-isp
drwxr-xr-x 2 surgemail root 4096 Jul 3 0:01 surgemail-workplace
drwxr-xr-x 3 netwin bin 4096 Jul 4 2001 watchdog
drwxr-xr-x 3 pnftp bin 4096 Mar 21 2001 webimap
drwxr-xr-x 3 pnftp root 4096 Apr 28 21:30 webmail
drwxr-xr-x 3 pnftp bin 4096 Jun 30 18:23 webnews
drwxr-xr-x 2 pnftp root 4096 Jan 30 20:31 webshareit
drwxr-xr-x 2 netwin bin 4096 Sep 20 1999 webtwin
drwxr-xr-x 4 pnftp root 4096 Jul 8 17:07 beta
lrwxrwxrwx 1 pnftp pnftp 12 Mar 18 15:48 wmail.exe -> wmail30h.exe
-rw-r--r-- 1 pnftp pnftp 2312192 Feb 19 15:33 wmail30h.exe
-rw-r--r-- 1 pnftp pnftp 3360893 Feb 21 19:24 wmail30h_aix4.tar.Z
-rw-r--r-- 1 pnftp pnftp 3508885 Mar 18 15:47 wmail30h_bsdi4.tar.Z
-rw-r--r-- 1 pnftp pnftp 2693234 Feb 19 15:47 wmail30h_freebsd.tar.Z
-rw-r--r-- 1 pnftp pnftp 2640047 Feb 19 15:38 wmail30h_freebsd3.tar.Z
-rw-r--r-- 1 pnftp pnftp 2654381 Feb 19 15:43 wmail30h_freebsd4.tar.Z
-rw-r--r-- 1 pnftp pnftp 3005333 Mar 18 18:21 wmail30h_hpux.tar.Z
-rw-r--r-- 1 pnftp pnftp 2779942 Feb 19 15:52 wmail30h_linux.tar.Z
-rw-r--r-- 1 pnftp pnftp 2782353 Feb 19 15:58 wmail30h_linuxlibc6.tar.Z
-rw-r--r-- 1 pnftp pnftp 1783391 Feb 19 16:01 wmail30h_linuxppc.tar.gz
-rw-r--r-- 1 pnftp pnftp 2758233 Mar 18 15:47 wmail30h_macosx_aqua.tar.Z
-rw-r--r-- 1 pnftp pnftp 3113365 Mar 18 15:47 wmail30h_osf.tar.Z
-rw-r--r-- 1 pnftp pnftp 1779720 Apr 28 21:30 wmail30h_raq3.tar.gz
-rw-r--r-- 1 pnftp pnftp 1789173 Mar 11 16:38 wmail30h_raq4.tar.gz
-rw-r--r-- 1 pnftp pnftp 2846045 Feb 19 16:06 wmail30h_solaris.tar.Z
-rw-r--r-- 1 pnftp pnftp 2858946 Feb 19 16:11 wmail30h_solarisx86.tar.Z
226 Transfer complete.
ftp> close
221 Closing connection - goodbye!
ftp>

View file

@ -0,0 +1,52 @@
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
07-07-2002 21:37:00 <DIR> cgimail
05-02-2002 17:38:00 <DIR> dbabble
07-01-2001 00:00:00 <DIR> dek_temp
07-01-2001 00:00:00 <DIR> deye
02-18-2002 17:50:00 <DIR> dfree
07-01-2001 00:00:00 <DIR> dgate
01-31-2002 15:18:00 <DIR> discontinued
07-07-2002 21:28:00 <DIR> dmail
06-30-2002 17:56:00 <DIR> dmailweb
07-10-2002 01:40:00 <DIR> dnews
07-01-2001 00:00:00 <DIR> dnewsweb
09-04-2001 00:00:00 <DIR> dnotice
05-06-2002 16:58:00 <DIR> fengate
05-28-2002 19:01:00 <DIR> ferngate
07-01-2001 00:00:00 <DIR> jeeves
06-27-2002 20:10:00 <DIR> misc
07-04-2002 21:13:00 <DIR> netauth
02-08-1999 00:00:00 <DIR> poppassd
07-09-2002 01:39:00 <DIR> surgeftp
07-03-2002 00:00:00 <DIR> surgemail
07-03-2002 00:01:00 <DIR> surgemail-enterprise
07-03-2002 00:01:00 <DIR> surgemail-home
07-03-2002 00:01:00 <DIR> surgemail-isp
07-03-2002 00:01:00 <DIR> surgemail-workplace
07-04-2001 00:00:00 <DIR> watchdog
03-21-2001 00:00:00 <DIR> webimap
04-28-2002 21:30:00 <DIR> webmail
06-30-2002 18:23:00 <DIR> webnews
01-30-2002 20:31:00 <DIR> webshareit
09-20-1999 00:00:00 <DIR> webtwin
07-08-2002 17:07:00 <DIR> beta
03-18-2002 15:48:00 <JUNCTION> wmail.exe -> wmail30h.exe
02-19-2002 15:33:00 2312192 wmail30h.exe
02-21-2002 19:24:00 3360893 wmail30h_aix4.tar.Z
03-18-2002 15:47:00 3508885 wmail30h_bsdi4.tar.Z
02-19-2002 15:47:00 2693234 wmail30h_freebsd.tar.Z
02-19-2002 15:38:00 2640047 wmail30h_freebsd3.tar.Z
02-19-2002 15:43:00 2654381 wmail30h_freebsd4.tar.Z
03-18-2002 18:21:00 3005333 wmail30h_hpux.tar.Z
02-19-2002 15:52:00 2779942 wmail30h_linux.tar.Z
02-19-2002 15:58:00 2782353 wmail30h_linuxlibc6.tar.Z
02-19-2002 16:01:00 1783391 wmail30h_linuxppc.tar.gz
03-18-2002 15:47:00 2758233 wmail30h_macosx_aqua.tar.Z
03-18-2002 15:47:00 3113365 wmail30h_osf.tar.Z
04-28-2002 21:30:00 1779720 wmail30h_raq3.tar.gz
03-11-2002 16:38:00 1789173 wmail30h_raq4.tar.gz
02-19-2002 16:06:00 2846045 wmail30h_solaris.tar.Z
02-19-2002 16:11:00 2858946 wmail30h_solarisx86.tar.Z

View file

@ -0,0 +1,38 @@
ftp> open ftp.jgaa.com
Connected to ftp.jgaa.com.
220-Jgaa's official FTP server
WarFTPd 1.81.00 (Mar 3 2002) Ready
(C)opyright 1996 - 2002 by Jarle (jgaa) Aase - all rights reserved.
220 Please enter your user name.
Name (ftp.jgaa.com:cyp):
230 User logged in.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> passive
Passive mode on.
ftp> ls
227 Entering Passive Mode (80,239,13,229,14,199)
125 Using existing ASCII mode data connection for /bin/ls (1220 bytes).
total 5127
dr-xr--r-- 1 root root 0 Apr 22 2009 .
dr-xr--r-- 1 root root 0 Apr 22 2009 ..
-r-xr--r-- 1 root root 359807 Mar 13 2000 adns-0.6-win32-01.zip
-r-xr--r-- 1 root root 77 Oct 17 2000 adns-0.6-win32-01.zip.md5
-r-xr--r-- 1 root root 218767 Nov 11 2000 cfs-1.3.3-8bit-fix.r2.tgz
-r-xr--r-- 1 root root 1606 Jun 13 2000 cfs-1.3.3-eight-bit-fix.diff.tar.gz
-r-xr--r-- 1 root root 3327 Oct 19 2000 chkmailspool-1.0.tgz
-r-xr--r-- 1 root root 9356 Oct 21 2000 chkmailspool-1.1.tgz
-r-xr--r-- 1 root root 32742 Feb 1 2000 iisstat-1.2.zip
-r-xr--r-- 1 root root 71 Oct 17 2000 iisstat-1.2.zip.md5
-r-xr--r-- 1 root root 27531 Aug 14 1999 inshtml.zip
-r-xr--r-- 1 root root 67 Oct 17 2000 inshtml.zip.md5
-r-xr--r-- 1 root root 23780 Aug 14 1999 netcps.zip
-r-xr--r-- 1 root root 66 Oct 17 2000 netcps.zip.md5
-r-xr--r-- 1 root root 1057919 Nov 3 2001 openssl-0.9.6b-win32.zip
-r-xr--r-- 1 root root 56823 Jan 28 2001 passgen-2.0.zip
-r-xr--r-- 1 root root 826880 May 25 1997 warftpd-version2-public-source.zip
-r-xr--r-- 1 root root 90 Oct 17 2000 warftpd-version2-public-source.zip.md5
226 Transfer complete. 1220 bytes in 0.01 sec. (119.141 Kb/s)
ftp> close
221 Goodbye. Control connection closed.
ftp>

View file

@ -0,0 +1,22 @@
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
04-22-2009 00:00:00 <DIR> .
04-22-2009 00:00:00 <DIR> ..
03-13-2000 00:00:00 359807 adns-0.6-win32-01.zip
10-17-2000 00:00:00 77 adns-0.6-win32-01.zip.md5
11-11-2000 00:00:00 218767 cfs-1.3.3-8bit-fix.r2.tgz
06-13-2000 00:00:00 1606 cfs-1.3.3-eight-bit-fix.diff.tar.gz
10-19-2000 00:00:00 3327 chkmailspool-1.0.tgz
10-21-2000 00:00:00 9356 chkmailspool-1.1.tgz
02-01-2000 00:00:00 32742 iisstat-1.2.zip
10-17-2000 00:00:00 71 iisstat-1.2.zip.md5
08-14-1999 00:00:00 27531 inshtml.zip
10-17-2000 00:00:00 67 inshtml.zip.md5
08-14-1999 00:00:00 23780 netcps.zip
10-17-2000 00:00:00 66 netcps.zip.md5
11-03-2001 00:00:00 1057919 openssl-0.9.6b-win32.zip
01-28-2001 00:00:00 56823 passgen-2.0.zip
05-25-1997 00:00:00 826880 warftpd-version2-public-source.zip
10-17-2000 00:00:00 90 warftpd-version2-public-source.zip.md5

View file

@ -0,0 +1,41 @@
ftp> open ftp.webstar.com
Connected to ftp.webstar.com.
220 FTP server ready.
Name (ftp.webstar.com:cyp):
331 Anonymous login OK, send login as password.
230 User logged in.
Remote system type is UNIX.
ftp> pwd
257 "/" is the current directory.
ftp> syst
215 UNIX WebSTAR FTP.
ftp> cd products
250 CWD OK, "/products".
ftp> cd WebStar
250 CWD OK, "/products/WebStar".
ftp> cd Updates
250 CWD OK, "/products/WebStar/Updates".
ftp> ls
200 PORT OK, IP address 134.93.247.34 port 49247
150 Opening data connection.
drwx------ 0 owner group 1 Jan 30 17:16 bundleup
drwx------ 0 owner group 2 Nov 08 2001 docs
drwx------ 0 owner group 12 Nov 08 2001 extending_webstar
drwx------ 0 owner group 2 Apr 25 09:40 Products
drwx------ 0 owner group 1 Jan 30 16:20 updates
drwx------ 0 owner group 11 Jan 30 17:16 webstar_dev
drwx------ 0 owner group 2 May 01 15:46 WebSTAR
drwx------ 0 owner group 15 May 13 09:54 Installers
drwx------ 0 owner group 8 Apr 25 09:59 Updates
drwx------ 0 owner group 7 Apr 25 10:00 Plug-ins
drwx------ 0 owner group 2 Apr 06 2001 SSL
-rwx------ 0 owner group 1605421 Mar 30 2001 webstar1.3.2_updater.sea.hqx
-rwx------ 0 owner group 6883859 Mar 30 2001 WebSTAR211installer.sea.hqx
-rwx------ 0 owner group 7366223 Mar 30 2001 WebSTAR211updater.sea.hqx
-rwx------ 0 owner group 13415184 Mar 30 2001 WebSTAR302updater.sea.hqx
drwx------ 0 owner group 4 Apr 05 2001 WebSTAR_44
drwx------ 0 owner group 2 Apr 25 10:00 WebSTAR_V
226 Transfer complete.
ftp> close
221 Goodbye.
ftp>

View file

@ -0,0 +1,21 @@
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
01-30-2002 17:16:00 <DIR> bundleup
11-08-2001 00:00:00 <DIR> docs
11-08-2001 00:00:00 <DIR> extending_webstar
04-25-2002 09:40:00 <DIR> Products
01-30-2002 16:20:00 <DIR> updates
01-30-2002 17:16:00 <DIR> webstar_dev
05-01-2002 15:46:00 <DIR> WebSTAR
05-13-2002 09:54:00 <DIR> Installers
04-25-2002 09:59:00 <DIR> Updates
04-25-2002 10:00:00 <DIR> Plug-ins
04-06-2001 00:00:00 <DIR> SSL
03-30-2001 00:00:00 1605421 webstar1.3.2_updater.sea.hqx
03-30-2001 00:00:00 6883859 WebSTAR211installer.sea.hqx
03-30-2001 00:00:00 7366223 WebSTAR211updater.sea.hqx
03-30-2001 00:00:00 13415184 WebSTAR302updater.sea.hqx
04-05-2001 00:00:00 <DIR> WebSTAR_44
04-25-2002 10:00:00 <DIR> WebSTAR_V

View file

@ -0,0 +1,68 @@
ftp> open ftp.microsoft.com
220 Microsoft FTP Service
Name (ftp.microsoft.com:cyp):
331 Anonymous access allowed, send identity (e-mail name) as password.
230-This is FTP.Microsoft.Com
230 Anonymous user logged in.
Remote system type is Windows_NT.
ftp> quote dirstyle
200 MSDOS-like directory output is on
ftp> quote dirstyle
200 MSDOS-like directory output is off
ftp> ls
200 PORT command successful.
150 Opening ASCII mode data connection for /bin/ls.
dr-xr-xr-x 1 owner group 0 Feb 25 2000 channel
dr-xr-xr-x 1 owner group 0 Feb 25 2000 Education
dr-xr-xr-x 1 owner group 0 Feb 25 2000 enterprise
dr-xr-xr-x 1 owner group 0 Jun 20 2001 ISN
dr-xr-xr-x 1 owner group 0 May 31 2001 Museum
dr-xr-xr-x 1 owner group 0 Feb 14 2001 TechNet
dr-xr-xr-x 1 owner group 0 Oct 24 2001 whql
dr-xr-xr-x 1 owner group 0 Feb 5 2001 20Year
dr-xr-xr-x 1 owner group 0 Sep 26 2000 AccessFoxPro
dr-xr-xr-x 1 owner group 0 Dec 21 2000 AlbGrp
dr-xr-xr-x 1 owner group 0 May 31 2001 Alexandra
dr-xr-xr-x 1 owner group 0 Jan 19 2001 anna
dr-xr-xr-x 1 owner group 0 Apr 6 2000 anz
dr-xr-xr-x 1 owner group 0 May 10 2000 Chase Bobko2
dr-xr-xr-x 1 owner group 0 Mar 29 2000 cnn
dr-xr-xr-x 1 owner group 0 Nov 21 2000 Darin
dr-xr-xr-x 1 owner group 0 Mar 9 2000 digitalchicago
dr-xr-xr-x 1 owner group 0 Sep 6 2000 Dublin
dr-xr-xr-x 1 owner group 0 Jan 30 2001 eleanorf
dr-xr-xr-x 1 owner group 0 Apr 26 2001 girvin
dr-xr-xr-x 1 owner group 0 Apr 26 2000 Hires
dr-xr-xr-x 1 owner group 0 Aug 15 2000 HR
-r-xr-xr-x 1 owner group 4368384 Oct 24 1999 IMG00022.PCD
dr-xr-xr-x 1 owner group 0 May 18 2001 jacubowsky
dr-xr-xr-x 1 owner group 0 Oct 12 2000 JFalvey
dr-xr-xr-x 1 owner group 0 Mar 28 2001 johnci
dr-xr-xr-x 1 owner group 0 Jul 14 2000 Karin
dr-xr-xr-x 1 owner group 0 Sep 7 2000 Kjung
dr-xr-xr-x 1 owner group 0 Sep 28 2000 LarryE
dr-xr-xr-x 1 owner group 0 Aug 17 2000 Larson
dr-xr-xr-x 1 owner group 0 Sep 12 2000 marion
dr-xr-xr-x 1 owner group 0 Aug 9 2000 ms25
dr-xr-xr-x 1 owner group 0 Nov 16 2000 MS25Brochure
dr-xr-xr-x 1 owner group 0 Mar 29 2000 MShistory
dr-xr-xr-x 1 owner group 0 Sep 5 2000 Neils
dr-xr-xr-x 1 owner group 0 Aug 2 2000 NLM
dr-xr-xr-x 1 owner group 0 Sep 6 2000 PageOne
dr-xr-xr-x 1 owner group 0 Jun 27 2000 pccomputing
dr-xr-xr-x 1 owner group 0 May 9 2001 pictures
dr-xr-xr-x 1 owner group 0 Jul 21 2000 pranks
dr-xr-xr-x 1 owner group 0 Aug 22 2000 Sean
dr-xr-xr-x 1 owner group 0 Aug 10 2000 SLeong
dr-xr-xr-x 1 owner group 0 Sep 7 2000 svr
dr-xr-xr-x 1 owner group 0 Jul 21 2000 Transcontinental
dr-xr-xr-x 1 owner group 0 Oct 23 2000 veronist
dr-xr-xr-x 1 owner group 0 Jun 15 2000 zoe
-r-xr-xr-x 1 owner group 2094926 Jul 14 2000 canprankdesk.tif
-r-xr-xr-x 1 owner group 95077 Jul 21 2000 Jon Kauffman Enjoys the Good Life.jpg
-r-xr-xr-x 1 owner group 52275 Jul 21 2000 Name Plate.jpg
-r-xr-xr-x 1 owner group 2250540 Jul 14 2000 Valentineoffprank-HiRes.jpg
226 Transfer complete.
ftp> close
221 Thank-You For Using Microsoft Products!
ftp>

View file

@ -0,0 +1,72 @@
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
cmnt: ftp> open ftp.microsoft.com
cmnt: Microsoft FTP Service
cmnt: Name (ftp.microsoft.com:cyp):
cmnt: 331 Anonymous access allowed, send identity (e-mail name) as password.
cmnt: 230-This is FTP.Microsoft.Com
cmnt: Anonymous user logged in.
cmnt: Remote system type is Windows_NT.
cmnt: ftp> quote dirstyle
cmnt: MSDOS-like directory output is on
cmnt: ftp> quote dirstyle
cmnt: MSDOS-like directory output is off
cmnt: ftp> ls
cmnt: PORT command successful.
cmnt: Opening ASCII mode data connection for /bin/ls.
list: 02-25-00 00:00AM <DIR> channel
list: 02-25-00 00:00AM <DIR> Education
list: 02-25-00 00:00AM <DIR> enterprise
list: 06-20-01 00:00AM <DIR> ISN
list: 05-31-01 00:00AM <DIR> Museum
list: 02-14-01 00:00AM <DIR> TechNet
list: 10-24-01 00:00AM <DIR> whql
list: 02-05-01 00:00AM <DIR> 20Year
list: 09-26-00 00:00AM <DIR> AccessFoxPro
list: 12-21-00 00:00AM <DIR> AlbGrp
list: 05-31-01 00:00AM <DIR> Alexandra
list: 01-19-01 00:00AM <DIR> anna
list: 04-06-00 00:00AM <DIR> anz
list: 05-10-00 00:00AM <DIR> Chase Bobko2
list: 03-29-00 00:00AM <DIR> cnn
list: 11-21-00 00:00AM <DIR> Darin
list: 03-09-00 00:00AM <DIR> digitalchicago
list: 09-06-00 00:00AM <DIR> Dublin
list: 01-30-01 00:00AM <DIR> eleanorf
list: 04-26-01 00:00AM <DIR> girvin
list: 04-26-00 00:00AM <DIR> Hires
list: 08-15-00 00:00AM <DIR> HR
list: 10-24-99 00:00AM 4368384 IMG00022.PCD
list: 05-18-01 00:00AM <DIR> jacubowsky
list: 10-12-00 00:00AM <DIR> JFalvey
list: 03-28-01 00:00AM <DIR> johnci
list: 07-14-00 00:00AM <DIR> Karin
list: 09-07-00 00:00AM <DIR> Kjung
list: 09-28-00 00:00AM <DIR> LarryE
list: 08-17-00 00:00AM <DIR> Larson
list: 09-12-00 00:00AM <DIR> marion
list: 08-09-00 00:00AM <DIR> ms25
list: 11-16-00 00:00AM <DIR> MS25Brochure
list: 03-29-00 00:00AM <DIR> MShistory
list: 09-05-00 00:00AM <DIR> Neils
list: 08-02-00 00:00AM <DIR> NLM
list: 09-06-00 00:00AM <DIR> PageOne
list: 06-27-00 00:00AM <DIR> pccomputing
list: 05-09-01 00:00AM <DIR> pictures
list: 07-21-00 00:00AM <DIR> pranks
list: 08-22-00 00:00AM <DIR> Sean
list: 08-10-00 00:00AM <DIR> SLeong
list: 09-07-00 00:00AM <DIR> svr
list: 07-21-00 00:00AM <DIR> Transcontinental
list: 10-23-00 00:00AM <DIR> veronist
list: 06-15-00 00:00AM <DIR> zoe
list: 07-14-00 00:00AM 2094926 canprankdesk.tif
list: 07-21-00 00:00AM 95077 Jon Kauffman Enjoys the Good Life.jpg
list: 07-21-00 00:00AM 52275 Name Plate.jpg
list: 07-14-00 00:00AM 2250540 Valentineoffprank-HiRes.jpg
junk: Transfer complete.
junk: ftp> close
junk: Thank-You For Using Microsoft Products!
junk: ftp>

View file

@ -0,0 +1,42 @@
ftp> open ftp.hethmon.com
Connected to ftp.hethmon.com.
220 Hethmon Brothers FTP Server for OS/2 ** BETA 2.0 **. Ready for new user.
Name (ftp.hethmon.com:cyp):
331 Guest logins allowed. Email address required for anonymous.
230 User foo@bar.com logged in.
Remote system type is UNIX.
ftp> cd pub
250 Directory changed to "/pub"
ftp> ls
200 Port command ok
150 Opening ASCII mode data connection.
d--x------ 1 ftp ftp 5 Mar 21 1999 ..
d--x------ 1 ftp ftp 0 Feb 16 2002 beta
---------- 1 ftp ftp 35573 May 5 2000 CheckQ2.zip
---------- 1 ftp ftp 1550521 May 5 2000 Ftpd106.zip
---------- 1 ftp ftp 35459 Feb 7 2001 hmailbox.zip
---------- 1 ftp ftp 55463 May 5 2000 HRxMail.zip
---------- 1 ftp ftp 34950 May 5 2000 HRxPass.zip
---------- 1 ftp ftp 1320184 May 5 2000 inetmail-1.2.1.pro.zip
---------- 1 ftp ftp 1218483 May 5 2000 inetmail-1.2.1.zip
---------- 1 ftp ftp 1615428 May 5 2000 inetmail-1.3.0.pro.zip
---------- 1 ftp ftp 1425567 May 5 2000 inetmail-1.3.0.zip
---------- 1 ftp ftp 1629145 Jan 9 2001 inetmail-1.3.18.zip
---------- 1 ftp ftp 1625314 Feb 7 2001 inetmail-1.3.18a.zip
---------- 1 ftp ftp 1407069 May 5 2000 inetmail-1.5.0.pro.zip
---------- 1 ftp ftp 1470338 Sep 27 2000 inetmail-1.5.31.pro.zip
---------- 1 ftp ftp 1583435 Jan 4 2001 inetmail-1.5.32.pro.zip
---------- 1 ftp ftp 1429364 May 5 2000 inetmail-1.5.5.pro.zip
---------- 1 ftp ftp 1471373 May 5 2000 inetmail-1.5.6.pro.zip
d--x------ 1 ftp ftp 0 Feb 8 2001 misc
---------- 1 ftp ftp 30913 May 5 2000 MXLookup.zip
d--x------ 1 ftp ftp 0 May 2 2002 perseus
d--x------ 1 ftp ftp 0 Feb 8 2001 rfcs
d--x------ 1 ftp ftp 0 Feb 8 2001 scripts
d--x------ 1 ftp ftp 0 Feb 8 2001 tcpip
d--x------ 1 ftp ftp 0 May 5 2000 testcase
d--x------ 1 ftp ftp 0 Feb 7 2001 tools
226 Data transfer complete
ftp> close
221 Service closing control connection.
ftp>

View file

@ -0,0 +1,30 @@
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
03-21-1999 00:00:00 <DIR> ..
02-16-2002 00:00:00 <DIR> beta
05-05-2000 00:00:00 35573 CheckQ2.zip
05-05-2000 00:00:00 1550521 Ftpd106.zip
02-07-2001 00:00:00 35459 hmailbox.zip
05-05-2000 00:00:00 55463 HRxMail.zip
05-05-2000 00:00:00 34950 HRxPass.zip
05-05-2000 00:00:00 1320184 inetmail-1.2.1.pro.zip
05-05-2000 00:00:00 1218483 inetmail-1.2.1.zip
05-05-2000 00:00:00 1615428 inetmail-1.3.0.pro.zip
05-05-2000 00:00:00 1425567 inetmail-1.3.0.zip
01-09-2001 00:00:00 1629145 inetmail-1.3.18.zip
02-07-2001 00:00:00 1625314 inetmail-1.3.18a.zip
05-05-2000 00:00:00 1407069 inetmail-1.5.0.pro.zip
09-27-2000 00:00:00 1470338 inetmail-1.5.31.pro.zip
01-04-2001 00:00:00 1583435 inetmail-1.5.32.pro.zip
05-05-2000 00:00:00 1429364 inetmail-1.5.5.pro.zip
05-05-2000 00:00:00 1471373 inetmail-1.5.6.pro.zip
02-08-2001 00:00:00 <DIR> misc
05-05-2000 00:00:00 30913 MXLookup.zip
05-02-2002 00:00:00 <DIR> perseus
02-08-2001 00:00:00 <DIR> rfcs
02-08-2001 00:00:00 <DIR> scripts
02-08-2001 00:00:00 <DIR> tcpip
05-05-2000 00:00:00 <DIR> testcase
02-07-2001 00:00:00 <DIR> tools

View file

@ -0,0 +1,29 @@
ftp> open tui.lincoln.ac.nz
Connected to tui.lincoln.ac.nz.
220 tui.lincoln.ac.nz Novell NetWare FTP Server (V1.80), Copyright (C) 1992-2000 MurkWorks Inc.
Name (tui.lincoln.ac.nz:cyp): 331 Anonymous Login OK, send id as password.
230-User logged in, Max Connect time 600 minutes (READONLY)
230 Current Directory : /
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls
200 Command Accepted
150 Opening connection for ASCII transfer
-rwx---r-- 1 anonymou other 1445 Apr 28 1994 ANON.DAT
-rwx---r-- 1 mcnaughp other 83 Apr 18 09:39 Copy of LABSPACE.SUM
drwx---r-x 2 anonymou other 512 Jul 11 21:04 JRBUTILS
-rwx---r-- 1 labspace other 91 Jul 13 02:04 LABSPACE.SUM
drwx---r-x 2 anonymou other 512 Jul 11 21:04 MAINT
drwx---r-x 2 anonymou other 512 Jul 11 21:04 MISC
drwx---r-x 2 anonymou other 512 Jul 11 21:04 PCOUNTER
drwx---r-x 2 helleupp other 512 Jul 11 21:05 PEGASUS
-rwx---r-- 1 anonymou other 13662 Aug 6 17:14 VOL$LOG.ERR
-rwx---r-- 1 anonymou other 27945 Sep 5 1994 WHATIS.MSC
226 Transfer complete
ftp> pwd
257 "/" is the current directory
ftp> syst
215 UNIX Type: L8 Version: NetWare MurkWorks, Inc. 1.80
ftp> close
221 Goodbye.
ftp>

View file

@ -0,0 +1,14 @@
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
04-28-1994 00:00:00 1445 ANON.DAT
04-18-2002 09:39:00 83 Copy of LABSPACE.SUM
07-11-2002 21:04:00 <DIR> JRBUTILS
07-13-2002 02:04:00 91 LABSPACE.SUM
07-11-2002 21:04:00 <DIR> MAINT
07-11-2002 21:04:00 <DIR> MISC
07-11-2002 21:04:00 <DIR> PCOUNTER
07-11-2002 21:05:00 <DIR> PEGASUS
08-06-2001 17:14:00 13662 VOL$LOG.ERR
09-05-1994 00:00:00 27945 WHATIS.MSC

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,84 @@
ftp> open casper.cs.uct.ac.za
Connected to casper.cs.uct.ac.za.
220 casper.cs.uct.ac.za FTP server (Version 6.00LS) ready.
Name (ftp.cs.uct.ac.za:cyp):
331 Guest login ok, send your email address as password.
230- Welcome to
230- __ _ _
230- / _| |_ _ __ ___ ___ _ _ ___| |_ __ _ ___ ______ _
230- | |_| __| '_ \ / __/ __|| | | |/ __| __| / _` |/ __| |_ / _` |
230- | _| |_| |_) | (__\__ \| |_| | (__| |_ | (_| | (__ _ / / (_| |
230- |_| \__| .__(_)___|___(_)__,_|\___|\__(_)__,_|\___(_)___\__,_|
230- |_|
230-
230- Publicly available downloads can be found in /pub.
230-
230- Do not put anything in /incoming unless it is by prior arrangement.
230- If we do not know what it is, it will be deleted.
230-
230- A complete listing of available files can be found in /pub/ls-lR.gz
230- and /pub/ls-lR. This list is updated daily at 02:00 SAST.
230-
230- Contents of /pub:
230- CVC/ - Collaborative Visual Computing Laboratory
230- DB/ - Database Laboratory
230- DNA/ - The Data Network Architectures Laboratory
230- FreeBSD/ - The FreeBSD Operating System
230- distfiles/ - ports source tarball's
230- releases/ - self-made releases
230- OpenBSD/ - The OpenBSD Operating System
230- windows/ - Software for Microsoft Windows
230- ssh/ - secure shell clients
230-
230- This FTP site is also searchable via archie,
230- and the web: http://ftp.cs.uct.ac.za:8000/ftpsearch
230-
230- UCT/UNINET users should also peruse the following
230- anonymous FTP servers for additional resources:
230-
230- ftp://ftp.leg.uct.ac.za/ [ http://www.leg.uct.ac.za/ ]
230- ftp://ftp.adamastor.ac.za/ [ http://ftp.adamastor.ac.za/ ]
230- ftp://cabbagewrath.its.uct.ac.za/ [ don't ask about the name ]
230-
230- --
230- ftp-admin@cs.uct.ac.za
230 Guest login ok, access restrictions apply.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> syst
215 UNIX Type: L8 Version: BSD-199506
ftp> ls
200 PORT command successful.
150 Opening ASCII mode data connection for '/bin/ls'.
total 1092
drwxr-xr-x 2 0 0 512 May 28 22:17 etc
drwx-wx-wt 2 0 0 512 Jul 1 02:15 incoming
drwx--x--x 2 0 0 512 Jul 3 12:19 private
drwxr-xr-x 9 0 0 512 Jul 11 01:02 pub
drwxr-xr-x 2 0 5 512 May 28 22:24 CVC
drwxr-xr-x 2 0 5 512 Jul 31 2000 DB
drwxr-xr-x 5 0 5 512 May 28 22:24 DNA
drwxr-xr-x 4 0 0 512 Jun 12 22:13 FreeBSD
drwxr-xr-x 3 0 5 512 May 28 22:24 OpenBSD
drwxr-xr-x 2 0 5 512 Jun 3 15:51 Solaris
-rw-r--r-- 1 0 0 158918 Jul 11 01:02 ls-lR
-rw-r--r-- 1 0 0 26569 Jul 11 01:02 ls-lR.gz
drwxr-xr-x 3 0 5 512 May 28 22:24 windows
lrwx------ 1 0 0 25 Jun 12 22:10 4.6-RELEASE -> releases/i386/4.6-RELEASE
lrwx------ 1 0 0 24 Jun 12 22:13 ISO-IMAGES -> releases/i386/ISO-IMAGES
-rw-r--r-- 1 0 5 157 May 28 22:27 README.TXT
-rw-r--r-- 1 0 5 872048 Sep 23 2001 cvsup-16.1e.tgz
lrwxr-xr-x 1 0 0 15 May 28 22:26 distfiles -> ports/distfiles
lrwxr-xr-x 1 0 0 14 Jun 6 17:12 packages -> ports/packages
drwxr-xr-x 5 0 0 512 Jun 23 18:47 ports
drwxr-xr-x 3 0 0 512 May 28 22:27 releases
-rw-r--r-- 1 0 0 1538 Mar 15 2001 ftpmotd
ftp> cd incoming
250 CWD command successful.
ftp> ls
200 PORT command successful.
150 Opening ASCII mode data connection for '/bin/ls'.
ftpd: .: Permission denied
226 Transfer complete.
ftp> close
221 Goodbye.

View file

@ -0,0 +1,26 @@
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
05-28-2002 22:17:00 <DIR> etc
07-01-2002 02:15:00 <DIR> incoming
07-03-2002 12:19:00 <DIR> private
07-11-2002 01:02:00 <DIR> pub
05-28-2002 22:24:00 <DIR> CVC
07-31-2000 00:00:00 <DIR> DB
05-28-2002 22:24:00 <DIR> DNA
06-12-2002 22:13:00 <DIR> FreeBSD
05-28-2002 22:24:00 <DIR> OpenBSD
06-03-2002 15:51:00 <DIR> Solaris
07-11-2002 01:02:00 158918 ls-lR
07-11-2002 01:02:00 26569 ls-lR.gz
05-28-2002 22:24:00 <DIR> windows
06-12-2002 22:10:00 <JUNCTION> 4.6-RELEASE -> releases/i386/4.6-RELEASE
06-12-2002 22:13:00 <JUNCTION> ISO-IMAGES -> releases/i386/ISO-IMAGES
05-28-2002 22:27:00 157 README.TXT
09-23-2001 00:00:00 872048 cvsup-16.1e.tgz
05-28-2002 22:26:00 <JUNCTION> distfiles -> ports/distfiles
06-06-2002 17:12:00 <JUNCTION> packages -> ports/packages
06-23-2002 18:47:00 <DIR> ports
05-28-2002 22:27:00 <DIR> releases
03-15-2001 00:00:00 1538 ftpmotd

View file

@ -0,0 +1,82 @@
ftp> open export.lcs.mit.edu
Connected to ftp.x.org.
220-Welcome to the ftp.x.org server.
220-
220-This server is provided and supported by The Open Group.
220-
220 ftp.x.org FTP server (Version wu-2.6.2(2) Mon Dec 17 13:03:41 GMT 2001) ready.
Name (export.lcs.mit.edu:cyp):
331 Guest login ok, send your complete e-mail address as password.
230-
230-Welcome to ftp.x.org, the X11 anonymous FTP archive of X.Org.
230-
230-PLEASE NOTE THE INCOMING FACILITY IS PRESENTLY UNAVAILABLE
230-
230-All activity is logged with your host name and email address.
230-
230-REPORTING PROBLEMS - Please report all problems to xorg_info@x.org.
230-
230-LOGIN PROBLEMS - If your FTP client crashes or hangs shortly after
230-login, try using a dash (-) as the first character of your password.
230-This turns off the informational messages that may be confusing
230-your ftp client.
230-
230-
230-Please read the file README
230- it was last modified on Tue Apr 24 15:33:13 2001 - 444 days ago
230 User ftp logged in. Access restrictions apply.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls
200 PORT command successful.
150 Opening ASCII mode data connection for /bin/ls.
total 5106
-rw-r--r-- 1 X.Org 91 May 7 2001 .banner
---------- 1 X.Org 0 May 30 2000 .notar
-rw-r--r-- 1 X.Org 885 May 27 1999 .welcome
-rw-r--r-- 1 X.Org 61 Jul 20 2001 30_days_changes
-rw-r--r-- 1 X.Org 61 Jul 20 2001 7_days_changes
-rw-r--r-- 1 X.Org 1456 Jul 20 2001 90_days_changes
-rw-r--r-- 1 X.Org 3075 Oct 7 1998 GettingBroadway
-rw-r--r-- 1 X.Org 3075 Oct 7 1998 GettingR6.3
-rw-r--r-- 1 X.Org 1847 Feb 1 1999 GettingR6.4
-rw-r--r-- 1 X.Org 1378 Aug 24 2000 GettingR6.5.1
-rw-r--r-- 1 X.Org 1229 Apr 24 2001 GettingR6.6
-rw-r--r-- 1 X.Org 194 Mar 11 1997 MIRROR.README
drwxr-xr-x 56 X.Org 22016 May 4 2001 R5contrib
-r--r--r-- 1 X.Org 1314 Apr 24 2001 README
-rw-r--r-- 2 X.Org 479 Nov 6 2001 banner2
lrwxrwxrwx 1 X.Org 7 Aug 8 2001 bin -> usr/bin
drwxr-xr-x 34 X.Org 1024 Nov 6 2001 contrib
d--x--x--x 2 X.Org 512 Aug 8 2001 dev
drwxr-xr-x 2 X.Org 512 Oct 12 1998 digest
d--x--x--x 3 X.Org 512 Aug 8 2001 etc
-rw-r--r-- 1 X.Org 2135632 Jul 20 2001 ls-lR
-rw-r--r-- 1 X.Org 376221 May 8 2001 ls-lR.Z
drwxr-xr-x 2 X.Org 512 Sep 29 1998 private
drwxr-xr-x 17 X.Org 512 May 4 2001 pub
drwxr-xr-x 2 X.Org 512 May 4 2001 rcsfaq
d--x--x--x 5 X.Org 512 Aug 8 2001 usr
-rw-r--r-- 2 X.Org 479 Nov 6 2001 welcome.msg
drwxr-xr-x 2 X.Org 512 May 4 2001 10R3
drwxr-xr-x 2 X.Org 512 May 4 2001 10R4
-rw-r--r-- 1 X.Org 9740 Mar 2 1999 Contrib.howto
drwxr-xr-x 9 X.Org 512 Jun 2 2001 DOCS
drwxr-xr-x 2 X.Org 512 May 4 2001 R1
drwxr-xr-x 2 X.Org 512 May 4 2001 R2
drwxr-xr-x 2 X.Org 512 May 4 2001 R3
drwxr-xr-x 7 X.Org 512 May 4 2001 R4
drwxr-xr-x 4 X.Org 512 May 4 2001 R5
drwxr-xr-x 4 X.Org 512 May 4 2001 R6
drwxr-xr-x 5 X.Org 512 May 4 2001 R6.1
drwxr-xr-x 6 X.Org 512 May 4 2001 R6.3
drwxr-xr-x 8 X.Org 512 Aug 10 2001 R6.4
drwxr-xr-x 7 X.Org 512 Aug 9 2001 R6.5.1
drwxr-xr-x 8 X.Org 512 May 2 2001 R6.6
drwxr-xr-x 10 X.Org 512 May 4 2001 unsupported
226 Transfer complete.
ftp> close
221-You have transferred 0 bytes in 0 files.
221-Total traffic for this session was 2686 bytes in 1 transfers.
221-Thank you for using the FTP service on ftp.x.org.
221 Goodbye.

View file

@ -0,0 +1,47 @@
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
05-07-2001 00:00:00 91 .banner
05-30-2000 00:00:00 0 .notar
05-27-1999 00:00:00 885 .welcome
07-20-2001 00:00:00 61 30_days_changes
07-20-2001 00:00:00 61 7_days_changes
07-20-2001 00:00:00 1456 90_days_changes
10-07-1998 00:00:00 3075 GettingBroadway
10-07-1998 00:00:00 3075 GettingR6.3
02-01-1999 00:00:00 1847 GettingR6.4
08-24-2000 00:00:00 1378 GettingR6.5.1
04-24-2001 00:00:00 1229 GettingR6.6
03-11-1997 00:00:00 194 MIRROR.README
05-04-2001 00:00:00 <DIR> R5contrib
04-24-2001 00:00:00 1314 README
11-06-2001 00:00:00 479 banner2
08-08-2001 00:00:00 <JUNCTION> bin -> usr/bin
11-06-2001 00:00:00 <DIR> contrib
08-08-2001 00:00:00 <DIR> dev
10-12-1998 00:00:00 <DIR> digest
08-08-2001 00:00:00 <DIR> etc
07-20-2001 00:00:00 2135632 ls-lR
05-08-2001 00:00:00 376221 ls-lR.Z
09-29-1998 00:00:00 <DIR> private
05-04-2001 00:00:00 <DIR> pub
05-04-2001 00:00:00 <DIR> rcsfaq
08-08-2001 00:00:00 <DIR> usr
11-06-2001 00:00:00 479 welcome.msg
05-04-2001 00:00:00 <DIR> 10R3
05-04-2001 00:00:00 <DIR> 10R4
03-02-1999 00:00:00 9740 Contrib.howto
06-02-2001 00:00:00 <DIR> DOCS
05-04-2001 00:00:00 <DIR> R1
05-04-2001 00:00:00 <DIR> R2
05-04-2001 00:00:00 <DIR> R3
05-04-2001 00:00:00 <DIR> R4
05-04-2001 00:00:00 <DIR> R5
05-04-2001 00:00:00 <DIR> R6
05-04-2001 00:00:00 <DIR> R6.1
05-04-2001 00:00:00 <DIR> R6.3
08-10-2001 00:00:00 <DIR> R6.4
08-09-2001 00:00:00 <DIR> R6.5.1
05-02-2001 00:00:00 <DIR> R6.6
05-04-2001 00:00:00 <DIR> unsupported

View file

@ -0,0 +1,21 @@
ftp> open ftp.netmanage.com
Connected to ftp.netmanage.com.
220 ProFTPD 1.2.4 Server (Netmanage FTP Server) [156.27.8.3]
Name (ftp.netmanage.com:cyp):
331 Anonymous login ok, send your complete email address as your password.
230 Anonymous access granted, restrictions apply.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls
200 PORT command successful.
150 Opening ASCII mode data connection for file list.
drwxr-xr-x 13 ftp ftp 344 Oct 17 2001 pub
drwxrwxr-x 7 ftp support 304 May 14 16:56 support
-rw-r--r-- 1 ftp ftp 508 Aug 19 1998 welcome.msg
226-Transfer complete.
226 Quotas off
ftp> syst
215 UNIX Type: L8
ftp> close
221 Goodbye.
ftp>

View file

@ -0,0 +1,7 @@
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
10-17-2001 00:00:00 <DIR> pub
05-14-2002 16:56:00 <DIR> support
08-19-1998 00:00:00 508 welcome.msg

View file

@ -0,0 +1,71 @@
ftp> open sunsite.unc.edu
Connected to sunsite.unc.edu.
220 divahouse.metalab.unc.edu FTP server (Version wu-2.6.1(4) Thu Nov 29 23:05:07 EST 2001) ready.
Name (sunsite.unc.edu:cyp):
331 Guest login ok, send your complete e-mail address as password.
230-
230- Welcome to ibiblio.org's FTP archives!
230- formerly known as MetaLab.unc.edu
230-
230-
230-For more information about services offered by ibiblio.org,
230-browse to http://ibiblio.org/faq
230-
230-You can access this archive via HTTP with the same URL.
230-
230-example: ftp://ibiblio.org/pub/Linux/ becomes
230- http://ibiblio.org/pub/Linux/, but we prefer you use FTP.
230-
230-You can get tarred directories if you issue a "get dirname.tar"
230-You can also get gzipped or compressed tarred directories by following
230-the .tar with .gz or .Z, respectively. Please don't issue either of
230-these commands to get Linux distributions. They are already compressed,
230-so this only generates unnecessary CPU overhead for us.
230-
230-************************************************************************
230-
230-Please use LSM documentation when submitting to the linux archive.
230-Anything submitted without an LSM will be rejected! You'll get an
230-email form letter about it if we can figure out who you are.
230-
230-To learn more about submitting an LSM,
230-see: http://www.ibiblio.org/pub/Linux/howtosubmit.html
230-or ftp://www.ibiblio.org/pub/Linux/HOW.TO.SUBMIT
230-
230-***********************************************************************
230-
230-If you mirror a site on ibiblio, please subscribe to our mirror list:
230-http://lists.ibiblio.org/mailman/listinfo/ibiblio-mirrors
230-
230-Have suggestions or questions? Please mail ftpkeeper@ibiblio.org.
230-
230-
230-Please read the file README
230- it was last modified on Tue Feb 19 09:46:53 2002 - 140 days ago
230 Guest login ok, access restrictions apply.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> syst
215 UNIX Type: L8
ftp> ls
200 PORT command successful.
150 Opening ASCII mode data connection for /bin/ls.
total 78744
-r--r--r-- 1 root other 80507411 Jul 9 06:09 IAFA-LISTINGS
-rw-r--r-- 1 root root 1393 Feb 19 14:46 README
dr-xr-xr-x 2 root other 4096 Mar 27 2001 bin
dr-xr-xr-x 2 root other 4096 Jul 16 1997 dev
dr-xr-xr-x 2 root other 4096 May 30 14:35 etc
drwxrwxrwx 18 ftp 20 4096 Jun 10 13:05 incoming
drwxr-xr-x 2 root root 4096 Mar 27 2001 lib
lrwxrwxrwx 1 root other 13 Mar 16 2001 ls-lR -> IAFA-LISTINGS
dr-xr-xr-x 18 root root 4096 May 31 19:46 pub
dr-xr-xr-x 3 root other 4096 Jun 26 2000 unc
dr-xr-xr-x 5 root other 4096 Jul 16 1997 usr
226 Transfer complete.
ftp> close
221-You have transferred 0 bytes in 0 files.
221-Total traffic for this session was 2777 bytes in 1 transfers.
221-Thank you for using the FTP service on divahouse.metalab.unc.edu.
221 Goodbye.
ftp>

View file

@ -0,0 +1,15 @@
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
07-09-2002 06:09:00 80507411 IAFA-LISTINGS
02-19-2002 14:46:00 1393 README
03-27-2001 00:00:00 <DIR> bin
07-16-1997 00:00:00 <DIR> dev
05-30-2002 14:35:00 <DIR> etc
06-10-2002 13:05:00 <DIR> incoming
03-27-2001 00:00:00 <DIR> lib
03-16-2001 00:00:00 <JUNCTION> ls-lR -> IAFA-LISTINGS
05-31-2002 19:46:00 <DIR> pub
06-26-2000 00:00:00 <DIR> unc
07-16-1997 00:00:00 <DIR> usr

View file

@ -0,0 +1,34 @@
Connected to acavax.lynchburg.edu.
220 acavax.lynchburg.edu MultiNet FTP Server Process V4.0(15) at Mon 1-Jul-02 10:51AM-EDT
Name (acavax.lynchburg.edu:cyp): 331 anonymous user ok. Send real ident as password.
230-Guest User FOO@BAR.COM logged into ACA:[ANONYMOUS] at Mon 1-Jul-02 10:51AM-EDT, job 2b69.
230 Access restrictions apply
Remote system type is VMS.
ftp> passive
Passive mode on.
ftp> pwd
257 "ACA:[ANONYMOUS]" is current directory.
ftp> ls
227 Entering passive mode; use PORT 161,115,147,1,10,31
150 List started.
ACA:[ANONYMOUS]
AUTOEXEC.BAT;1 %RMS-E-PRV, insufficient privilege or file protection violation
BOURNE.DIR;1 1 28-OCT-1994 10:05 [ANONYMOUS] (RWE,RWE,RE,RWE)
FTP_SERVER.LOG;8171 0 1-JUL-2002 10:51 [ANONYMOUS] (RWED,RWED,,)
LOGIN.COM;2 1 4-NOV-1994 14:09 [ANONYMOUS] (RWE,RWE,,)
NICELY.DIR;1 1 14-NOV-1994 14:17 [501,120] (RWED,RWED,RE,RE)
NWLINK.386;1 66 7-AUG-1995 14:32 [ANONYMOUS] (RWED,RWED,,RE)
PUB.DIR;1 1 27-JAN-1994 14:46 [ANONYMOUS] (RWE,RWE,RE,RWE)
README.FTP;1 %RMS-E-PRV, insufficient privilege or file protection violation
ROUSSOS.DIR;1 1 27-JAN-1994 14:48 [CS,ROUSSOS] (RWE,RWE,RE,R)
S67-50903.JPG;1 328 22-SEP-1998 16:19 [ANONYMOUS] (RWED,RWED,,)
S71-43543.JPG;1 310 22-SEP-1998 16:20 [ANONYMOUS] (RWED,RWED,,)
TEAGUE.DIR;1 1 1-JUL-1995 12:23 [ANONYMOUS] (RWE,RWE,RE,RE)
Total of 710 blocks in 12 files.
226 Transfer completed.
ftp> quit
221 QUIT command received. Goodbye.

View file

@ -0,0 +1,14 @@
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
10-28-1994 10:05:00 <DIR> BOURNE
07-01-2002 10:51:00 0 FTP_SERVER.LOG
11-04-1994 14:09:00 512 LOGIN.COM
11-14-1994 14:17:00 <DIR> NICELY
08-07-1995 14:32:00 33792 NWLINK.386
01-27-1994 14:46:00 <DIR> PUB
01-27-1994 14:48:00 <DIR> ROUSSOS
09-22-1998 16:19:00 167936 S67-50903.JPG
09-22-1998 16:20:00 158720 S71-43543.JPG
07-01-1995 12:23:00 <DIR> TEAGUE

View file

@ -0,0 +1,22 @@
This is a composite of 'difficult' VMS (MultiNet/UCX/CMU) LIST lines.
CAUTION WHILE EDITING - lines may have dangling CRs! (intentional)
Directory DISK$VOL:[DIR1.DIR2]
DISK$VOL:
ACA:[ANONYMOUS]
AUTOEXEC.BAT;1 %RMS-E-PRV, insufficient privilege or file protection violation
README.FTP;1 insufficient privilege or file protection violation
LOGIN.COM;2 1 4-NOV-1994 14:09 [ANONYMOUS] (RWE,RWE,,)
CII-MANUAL.TEX;1 213/216 29-JAN-1996 03:33:12 [ANONYMOU,ANONYMOUS] (RWED,RWED,,)
THIS-IS-A-LONG-VMS-FILENAME.WITH-CR-TO-NEXT-LINE 213/216 29-JAN-1996 03:33:12 [ANONYMOU,ANONYMOUS] (RWED,RWED,,)
ANOTHER-LONG-VMS-FILENAME.WITH-LF-TO-NEXT-LINE
213 29-JAN-1996 03:33 [ANONYMOU,ANONYMOUS] (RWED,RWED,,)
[A.DIR]CMU-VMS-IP-FTP-FILE;1 1/3 5-MAR-1993 18:09
MAX_FILESIZE.FILE;1 2199023255040/4294967295 5-MAR-1993 18:09
Total of 710 blocks in 12 files.
226 Transfer completed.
ftp> quit
221 QUIT command received. Goodbye.

View file

@ -0,0 +1,10 @@
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
11-04-1994 14:09:00 LOGIN.COM
01-29-1996 03:33:12 CII-MANUAL.TEX
01-29-1996 03:33:12 THIS-IS-A-LONG-VMS-FILENAME.WITH-CR-TO-NEXT-LINE
01-29-1996 03:33:00 ANOTHER-LONG-VMS-FILENAME.WITH-LF-TO-NEXT-LINE
03-05-1993 18:09:00 CMU-VMS-IP-FTP-FILE
03-05-1993 18:09:00 2199023255040 MAX_FILESIZE.FILE

View file

@ -0,0 +1,25 @@
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
DIRS += ['converters']
TEST_DIRS += ['test']
XPIDL_SOURCES += [
'mozITXTToHTMLConv.idl',
'nsIDirIndex.idl',
'nsIDirIndexListener.idl',
'nsIStreamConverter.idl',
'nsIStreamConverterService.idl',
'nsITXTToHTMLConv.idl',
]
SOURCES += [
'nsStreamConverterService.cpp',
]
XPIDL_MODULE = 'necko_strconv'
FINAL_LIBRARY = 'xul'

View file

@ -0,0 +1,88 @@
/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
Description: Currently only functions to enhance plain text with HTML tags.
<p>
Wrapper class for various parsing routines, that convert plain text to HTML.
They try to recognize cites, URLs, plain text formattting like *bold* etc.
See <http://www.bucksch.org/1/projects/mozilla/16507/> for a description.
*/
#include "nsIStreamConverter.idl"
%{C++
// {77c0e42a-1dd2-11b2-8ebf-edc6606f2f4b}
#define MOZITXTTOHTMLCONV_CID \
{ 0x77c0e42a, 0x1dd2, 0x11b2, \
{ 0x8e, 0xbf, 0xed, 0xc6, 0x60, 0x6f, 0x2f, 0x4b } }
#define MOZ_TXTTOHTMLCONV_CONTRACTID \
"@mozilla.org/txttohtmlconv;1"
%}
[scriptable, uuid(77c0e42a-1dd2-11b2-8ebf-edc6606f2f4b)]
interface mozITXTToHTMLConv : nsIStreamConverter {
const unsigned long kEntities = 0; // just convert < & > to &lt; &amp; and &gt;
const unsigned long kURLs = 1 << 1;
const unsigned long kGlyphSubstitution = 1 << 2; // Smilies, &reg; etc.
const unsigned long kStructPhrase = 1 << 3; // E.g. *bold* -> <strong>
/**
@param text: plain text to scan. May be a line, paragraph (recommended)
or just a substring.<p>
Must be non-escaped, pure unicode.<p>
<em>Note:</em> ScanTXT(a, o) + ScanTXT(b, o) may be !=
Scan(a + b, o)
@param whattodo: Bitfield describing the modes of operation
@result "<", ">" and "&" are escaped and HTML tags are inserted where
appropriate.
*/
wstring scanTXT(in wstring text, in unsigned long whattodo);
/**
Adds additional formatting to user edited text, that the user was too lazy
or "unknowledged" (DELETEME: is that a word?) to make.
<p>
<em>Note:</em> Don't use kGlyphSubstitution with this function. This option
generates tags, that are unuseable for UAs other than Mozilla. This would
be a data loss bug.
@param text: HTML source to scan. May be a line, paragraph (recommended)
or just a substring.<p>
Must be correct HTML. "<", ">" and "&" must be escaped,
other chars must be pure unicode.<p>
<em>Note:</em> ScanTXT(a, o) + ScanTXT(b, o) may be !=
Scan(a + b, o)
@param whattodo: Bitfield describing the modes of operation
@result Additional HTML tags are inserted where appropriate.
*/
wstring scanHTML(in wstring text, in unsigned long whattodo);
/**
@param line: line in original msg, possibly starting starting with
txt quote tags like ">"
@param logLineStart: pos in line, where the real content (logical line)
begins, i.e. pos after all txt quote tags.
E.g. position of "t" in "> > text".
Initial value must be 0, unless line is not real line.
@return Cite Level, i.e. number of txt quote tags found, i.e. number of
nested quotes.
*/
unsigned long citeLevelTXT(in wstring line,
out unsigned long logLineStart);
/**
@param a wide string to scan for the presence of a URL.
@param aLength --> the length of the buffer to be scanned
@param aPos --> the position in the buffer to start scanning for a url
aStartPos --> index into the start of a url (-1 if no url found)
aEndPos --> index of the last character in the url (-1 if no url found)
*/
void findURLInPlaintext(in wstring text, in long aLength, in long aPos, out long aStartPos, out long aEndPos);
};

View file

@ -0,0 +1,82 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsISupports.idl"
/** A class holding information about a directory index.
* These have no reference back to their original source -
* changing these attributes won't affect the directory
*/
[scriptable, uuid(23bbabd0-1dd2-11b2-86b7-aad68ae7d7e0)]
interface nsIDirIndex : nsISupports
{
/**
* Entry's type is unknown
*/
const unsigned long TYPE_UNKNOWN = 0;
/**
* Entry is a directory
*/
const unsigned long TYPE_DIRECTORY = 1;
/**
* Entry is a file
*/
const unsigned long TYPE_FILE = 2;
/**
* Entry is a symlink
*/
const unsigned long TYPE_SYMLINK = 3;
/**
* The type of the entry - one of the constants above
*/
attribute unsigned long type;
/**
* The content type - may be null if it is unknown.
* Unspecified for directories
*/
attribute string contentType;
/**
* The fully qualified filename, expressed as a uri
*
* This is encoded with the encoding specified in
* the nsIDirIndexParser, and is also escaped.
*/
attribute string location;
/**
* A description for the filename, which should be
* displayed by a viewer
*/
attribute wstring description;
/**
* File size, with -1 meaning "unknown"
*/
attribute long long size;
/**
* Last-modified time in seconds-since-epoch.
* -1 means unknown - this is valid, because there were no
* ftp servers in 1969
*/
attribute PRTime lastModified;
};
%{C++
#define NS_DIRINDEX_CID \
/* { f6913e2e-1dd1-11b2-84be-f455dee342af } */ \
{ 0xf6913e2e, \
0x1dd1, \
0x11b2, \
{ 0x84, 0xbe, 0xf4, 0x55, 0xde, 0xe3, 0x42, 0xaf } \
}
%}

View file

@ -0,0 +1,79 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsIStreamListener.idl"
interface nsIDirIndex;
/**
* This interface is used to receive contents of directory index listings
* from a protocol. They can then be transformed into an output format
* (such as rdf, html, etc)
*/
[scriptable, uuid(fae4e9a8-1dd1-11b2-b53c-8f3aa1bbf8f5)]
interface nsIDirIndexListener : nsISupports {
/**
* Called for each directory entry
*
* @param request - the request
* @param ctxt - opaque parameter
* @param index - new index to add
*/
void onIndexAvailable(in nsIRequest aRequest,
in nsISupports aCtxt,
in nsIDirIndex aIndex);
/**
* Called for each information line
*
* @param request - the request
* @param ctxt - opaque parameter
* @param info - new info to add
*/
void onInformationAvailable(in nsIRequest aRequest,
in nsISupports aCtxt,
in AString aInfo);
};
%{C++
#define NS_IDIRINDEXLISTENER_KEY "@mozilla.org/dirIndexListener;1"
%}
/**
* A parser for application/http-index-format
*/
[scriptable, uuid(38e3066c-1dd2-11b2-9b59-8be515c1ee3f)]
interface nsIDirIndexParser : nsIStreamListener {
/**
* The interface to use as a callback for new entries
*/
attribute nsIDirIndexListener listener;
/**
* The comment given, if any
* This result is only valid _after_ OnStopRequest has occurred,
* because it can occur anywhere in the datastream
*/
readonly attribute string comment;
/**
* The encoding to use
*/
attribute string encoding;
};
%{C++
#define NS_DIRINDEXPARSER_CID \
{ /* a0d6ad32-1dd1-11b2-aa55-a40187b54036 */ \
0xa0d6ad32, \
0x1dd1, \
0x11b2, \
{ 0xaa, 0x55, 0xa4, 0x01, 0x87, 0xb5, 0x40, 0x36 } \
}
#define NS_DIRINDEXPARSER_CONTRACTID "@mozilla.org/dirIndexParser;1"
%}

View file

@ -0,0 +1,100 @@
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsIStreamListener.idl"
interface nsIInputStream;
/**
* nsIStreamConverter provides an interface to implement when you have code
* that converts data from one type to another.
*
* Suppose you had code that converted plain text into HTML. You could implement
* this interface to allow everyone else to use your conversion logic using a
* standard api.
* <p>
* <b>STREAM CONVERTER USERS</b>
*
* There are currently two ways to use a stream converter:
* <ol>
* <li> <b>SYNCHRONOUS</b> Stream to Stream
* You can supply the service with a stream of type X
* and it will convert it to your desired output type and return
* a converted (blocking) stream to you.</li>
*
* <li> <b>ASYNCHRONOUS</b> nsIStreamListener to nsIStreamListener
* You can supply data directly to the converter by calling it's
* nsIStreamListener::OnDataAvailable() method. It will then
* convert that data from type X to your desired output type and
* return converted data to you via the nsIStreamListener you passed
* in by calling its OnDataAvailable() method.</li>
* </ol>
* <p>
*
* <b>STREAM CONVERTER SUPPLIERS</b>
*
* Registering a stream converter:
* Stream converter registration is a two step process. First of all the stream
* converter implementation must register itself with the component manager using
* a contractid in the format below. Second, the stream converter must add the contractid
* to the registry.
*
* Stream converter contractid format (the stream converter root key is defined in this
* file):
*
* <pre>@mozilla.org/streamconv;1?from=FROM_MIME_TYPE&to=TO_MIME_TYPE</pre>
*
* @author Jud Valeski
* @see nsIStreamConverterService
*/
[scriptable, uuid(0b6e2c69-5cf5-48b0-9dfd-c95950e2cc7b)]
interface nsIStreamConverter : nsIStreamListener {
/**
* <b>SYNCRONOUS VERSION</b>
* Converts a stream of one type, to a stream of another type.
*
* Use this method when you have a stream you want to convert.
*
* @param aFromStream The stream representing the original/raw data.
* @param aFromType The MIME type of aFromStream.
* @param aToType The MIME type of the returned stream.
* @param aCtxt Either an opaque context, or a converter specific context
* (implementation specific).
* @return The converted stream. NOTE: The returned stream may not
* already be converted. An efficient stream converter
* implementation will converter data on demand rather than
* buffering the converted data until it is used.
*/
nsIInputStream convert(in nsIInputStream aFromStream,
in string aFromType,
in string aToType,
in nsISupports aCtxt);
/**
* <b>ASYNCRONOUS VERSION</b>
* Converts data arriving via the converter's nsIStreamListener::OnDataAvailable()
* method from one type to another, pushing the converted data out to the caller
* via aListener::OnDataAvailable().
*
* Use this method when you want to proxy (and convert) nsIStreamListener callbacks
* asynchronously.
*
* @param aFromType The MIME type of the original/raw data.
* @param aToType The MIME type of the converted data.
* @param aListener The listener who receives the converted data.
* @param aCtxt Either an opaque context, or a converter specific context
* (implementation specific).
*/
void asyncConvertData(in string aFromType,
in string aToType,
in nsIStreamListener aListener,
in nsISupports aCtxt);
};
%{C++
#define NS_ISTREAMCONVERTER_KEY "@mozilla.org/streamconv;1"
%}

View file

@ -0,0 +1,80 @@
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsISupports.idl"
interface nsIInputStream;
interface nsIStreamListener;
%{C++
#define NS_ISTREAMCONVERTER_KEY "@mozilla.org/streamconv;1"
%}
/**
* The nsIStreamConverterService is a higher level stream converter factory
* responsible for locating and creating stream converters
* (nsIStreamConverter).
*
* This service retrieves an interface that can convert data from a particular
* MIME type, to a particular MIME type. It is responsible for any intermediary
* conversion required in order to get from X to Z, assuming direct conversion
* is not possible.
*
* @author Jud Valeski
* @see nsIStreamConverter
*/
[scriptable, uuid(f2b1ab53-f0bd-4adb-9365-e59b1701a258)]
interface nsIStreamConverterService : nsISupports {
/**
* Tests whether conversion between the two specified types is possible.
* This is cheaper than calling convert()/asyncConvertData(); it is not
* necessary to call this function before calling one of those, though.
*/
boolean canConvert(in string aFromType, in string aToType);
/**
* <b>SYNCHRONOUS VERSION</b>
* Converts a stream of one type, to a stream of another type.
*
* Use this method when you have a stream you want to convert.
*
* @param aFromStream The stream representing the original/raw data.
* @param aFromType The MIME type of aFromStream.
* @param aToType The MIME type of the returned stream.
* @param aContext Either an opaque context, or a converter specific
* context (implementation specific).
* @return The converted stream. NOTE: The returned stream
* may not already be converted. An efficient stream
* converter implementation will convert data on
* demand rather than buffering the converted data
* until it is used.
*/
nsIInputStream convert(in nsIInputStream aFromStream,
in string aFromType,
in string aToType,
in nsISupports aContext);
/**
* <b>ASYNCHRONOUS VERSION</b>
* Retrieves a nsIStreamListener that receives the original/raw data via its
* nsIStreamListener::OnDataAvailable() callback, then converts and pushes
* the data to aListener.
*
* Use this method when you want to proxy (and convert) nsIStreamListener
* callbacks asynchronously.
*
* @param aFromType The MIME type of the original/raw data.
* @param aToType The MIME type of the converted data.
* @param aListener The listener that receives the converted data.
* @param aCtxt Either an opaque context, or a converter specific
* context (implementation specific).
* @return A nsIStreamListener that receives data via its
* OnDataAvailable() method.
*/
nsIStreamListener asyncConvertData(in string aFromType,
in string aToType,
in nsIStreamListener aListener,
in nsISupports aContext);
};

View file

@ -0,0 +1,25 @@
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsIStreamConverter.idl"
[scriptable, uuid(933355f6-1dd2-11b2-a9b0-d335b9e35983)]
interface nsITXTToHTMLConv : nsIStreamConverter {
/**
* @param text: Title to set for the HTML document. Only applicable if
* preFormatHTML(true) is called.
* @result The given title will be used to form an HTML document
* from the plain text document.
*/
void setTitle(in wstring text);
/**
* @param value: true to use an HTML header and footer on the document,
* false to omit it.
* @result The document will use a header and footer if value is
* true.
*/
void preFormatHTML(in boolean value);
};

View file

@ -0,0 +1,558 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
*
* This Original Code has been modified by IBM Corporation.
* Modifications made by IBM described herein are
* Copyright (c) International Business Machines
* Corporation, 2000
*
* Modifications to Mozilla code or documentation
* identified per MPL Section 3.3
*
* Date Modified by Description of modification
* 03/27/2000 IBM Corp. Added PR_CALLBACK for Optlink
* use in OS2
*/
#include "nsStreamConverterService.h"
#include "nsIComponentRegistrar.h"
#include "nsAutoPtr.h"
#include "nsString.h"
#include "nsIAtom.h"
#include "nsDeque.h"
#include "nsIInputStream.h"
#include "nsIStreamConverter.h"
#include "nsICategoryManager.h"
#include "nsXPCOM.h"
#include "nsISupportsPrimitives.h"
#include "nsCOMArray.h"
#include "nsTArray.h"
#include "nsServiceManagerUtils.h"
#include "nsISimpleEnumerator.h"
///////////////////////////////////////////////////////////////////
// Breadth-First-Search (BFS) algorithm state classes and types.
// Used to establish discovered verticies.
enum BFScolors {white, gray, black};
// BFS hashtable data class.
struct BFSTableData {
nsCString key;
BFScolors color;
int32_t distance;
nsAutoPtr<nsCString> predecessor;
explicit BFSTableData(const nsACString& aKey)
: key(aKey), color(white), distance(-1)
{
}
};
////////////////////////////////////////////////////////////
// nsISupports methods
NS_IMPL_ISUPPORTS(nsStreamConverterService, nsIStreamConverterService)
////////////////////////////////////////////////////////////
// nsIStreamConverterService methods
////////////////////////////////////////////////////////////
// nsStreamConverterService methods
nsStreamConverterService::nsStreamConverterService()
{
}
nsStreamConverterService::~nsStreamConverterService() = default;
// Builds the graph represented as an adjacency list (and built up in
// memory using an nsObjectHashtable and nsCOMArray combination).
//
// :BuildGraph() consults the category manager for all stream converter
// CONTRACTIDS then fills the adjacency list with edges.
// An edge in this case is comprised of a FROM and TO MIME type combination.
//
// CONTRACTID format:
// @mozilla.org/streamconv;1?from=text/html&to=text/plain
// XXX curently we only handle a single from and to combo, we should repeat the
// XXX registration process for any series of from-to combos.
// XXX can use nsTokenizer for this.
//
nsresult
nsStreamConverterService::BuildGraph() {
nsresult rv;
nsCOMPtr<nsICategoryManager> catmgr(do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsISimpleEnumerator> entries;
rv = catmgr->EnumerateCategory(NS_ISTREAMCONVERTER_KEY, getter_AddRefs(entries));
if (NS_FAILED(rv)) return rv;
// go through each entry to build the graph
nsCOMPtr<nsISupports> supports;
nsCOMPtr<nsISupportsCString> entry;
rv = entries->GetNext(getter_AddRefs(supports));
while (NS_SUCCEEDED(rv)) {
entry = do_QueryInterface(supports);
// get the entry string
nsAutoCString entryString;
rv = entry->GetData(entryString);
if (NS_FAILED(rv)) return rv;
// cobble the entry string w/ the converter key to produce a full contractID.
nsAutoCString contractID(NS_ISTREAMCONVERTER_KEY);
contractID.Append(entryString);
// now we've got the CONTRACTID, let's parse it up.
rv = AddAdjacency(contractID.get());
if (NS_FAILED(rv)) return rv;
rv = entries->GetNext(getter_AddRefs(supports));
}
return NS_OK;
}
// XXX currently you can not add the same adjacency (i.e. you can't have multiple
// XXX stream converters registering to handle the same from-to combination. It's
// XXX not programatically prohibited, it's just that results are un-predictable
// XXX right now.
nsresult
nsStreamConverterService::AddAdjacency(const char *aContractID) {
nsresult rv;
// first parse out the FROM and TO MIME-types.
nsAutoCString fromStr, toStr;
rv = ParseFromTo(aContractID, fromStr, toStr);
if (NS_FAILED(rv)) return rv;
// Each MIME-type is a vertex in the graph, so first lets make sure
// each MIME-type is represented as a key in our hashtable.
nsCOMArray<nsIAtom> *fromEdges = mAdjacencyList.Get(fromStr);
if (!fromEdges) {
// There is no fromStr vertex, create one.
fromEdges = new nsCOMArray<nsIAtom>();
mAdjacencyList.Put(fromStr, fromEdges);
}
if (!mAdjacencyList.Get(toStr)) {
// There is no toStr vertex, create one.
mAdjacencyList.Put(toStr, new nsCOMArray<nsIAtom>());
}
// Now we know the FROM and TO types are represented as keys in the hashtable.
// Let's "connect" the verticies, making an edge.
nsCOMPtr<nsIAtom> vertex = NS_Atomize(toStr);
if (!vertex) return NS_ERROR_OUT_OF_MEMORY;
NS_ASSERTION(fromEdges, "something wrong in adjacency list construction");
if (!fromEdges)
return NS_ERROR_FAILURE;
return fromEdges->AppendObject(vertex) ? NS_OK : NS_ERROR_FAILURE;
}
nsresult
nsStreamConverterService::ParseFromTo(const char *aContractID, nsCString &aFromRes, nsCString &aToRes) {
nsAutoCString ContractIDStr(aContractID);
int32_t fromLoc = ContractIDStr.Find("from=");
int32_t toLoc = ContractIDStr.Find("to=");
if (-1 == fromLoc || -1 == toLoc ) return NS_ERROR_FAILURE;
fromLoc = fromLoc + 5;
toLoc = toLoc + 3;
nsAutoCString fromStr, toStr;
ContractIDStr.Mid(fromStr, fromLoc, toLoc - 4 - fromLoc);
ContractIDStr.Mid(toStr, toLoc, ContractIDStr.Length() - toLoc);
aFromRes.Assign(fromStr);
aToRes.Assign(toStr);
return NS_OK;
}
typedef nsClassHashtable<nsCStringHashKey, BFSTableData> BFSHashTable;
// nsObjectHashtable enumerator functions.
class CStreamConvDeallocator : public nsDequeFunctor {
public:
void* operator()(void* anObject) override {
nsCString *string = (nsCString*)anObject;
delete string;
return 0;
}
};
// walks the graph using a breadth-first-search algorithm which generates a discovered
// verticies tree. This tree is then walked up (from destination vertex, to origin vertex)
// and each link in the chain is added to an nsStringArray. A direct lookup for the given
// CONTRACTID should be made prior to calling this method in an attempt to find a direct
// converter rather than walking the graph.
nsresult
nsStreamConverterService::FindConverter(const char *aContractID, nsTArray<nsCString> **aEdgeList) {
nsresult rv;
if (!aEdgeList) return NS_ERROR_NULL_POINTER;
*aEdgeList = nullptr;
// walk the graph in search of the appropriate converter.
uint32_t vertexCount = mAdjacencyList.Count();
if (0 >= vertexCount) return NS_ERROR_FAILURE;
// Create a corresponding color table for each vertex in the graph.
BFSHashTable lBFSTable;
for (auto iter = mAdjacencyList.Iter(); !iter.Done(); iter.Next()) {
const nsACString &key = iter.Key();
MOZ_ASSERT(iter.UserData(), "no data in the table iteration");
lBFSTable.Put(key, new BFSTableData(key));
}
NS_ASSERTION(lBFSTable.Count() == vertexCount, "strmconv BFS table init problem");
// This is our source vertex; our starting point.
nsAutoCString fromC, toC;
rv = ParseFromTo(aContractID, fromC, toC);
if (NS_FAILED(rv)) return rv;
BFSTableData *data = lBFSTable.Get(fromC);
if (!data) {
return NS_ERROR_FAILURE;
}
data->color = gray;
data->distance = 0;
auto *dtorFunc = new CStreamConvDeallocator();
nsDeque grayQ(dtorFunc);
// Now generate the shortest path tree.
grayQ.Push(new nsCString(fromC));
while (0 < grayQ.GetSize()) {
nsCString *currentHead = (nsCString*)grayQ.PeekFront();
nsCOMArray<nsIAtom> *data2 = mAdjacencyList.Get(*currentHead);
if (!data2) return NS_ERROR_FAILURE;
// Get the state of the current head to calculate the distance of each
// reachable vertex in the loop.
BFSTableData *headVertexState = lBFSTable.Get(*currentHead);
if (!headVertexState) return NS_ERROR_FAILURE;
int32_t edgeCount = data2->Count();
for (int32_t i = 0; i < edgeCount; i++) {
nsIAtom* curVertexAtom = data2->ObjectAt(i);
auto *curVertex = new nsCString();
curVertexAtom->ToUTF8String(*curVertex);
BFSTableData *curVertexState = lBFSTable.Get(*curVertex);
if (!curVertexState) {
delete curVertex;
return NS_ERROR_FAILURE;
}
if (white == curVertexState->color) {
curVertexState->color = gray;
curVertexState->distance = headVertexState->distance + 1;
curVertexState->predecessor = new nsCString(*currentHead);
grayQ.Push(curVertex);
} else {
delete curVertex; // if this vertex has already been discovered, we don't want
// to leak it. (non-discovered vertex's get cleaned up when
// they're popped).
}
}
headVertexState->color = black;
nsCString *cur = (nsCString*)grayQ.PopFront();
delete cur;
cur = nullptr;
}
// The shortest path (if any) has been generated and is represented by the chain of
// BFSTableData->predecessor keys. Start at the bottom and work our way up.
// first parse out the FROM and TO MIME-types being registered.
nsAutoCString fromStr, toMIMEType;
rv = ParseFromTo(aContractID, fromStr, toMIMEType);
if (NS_FAILED(rv)) return rv;
// get the root CONTRACTID
nsAutoCString ContractIDPrefix(NS_ISTREAMCONVERTER_KEY);
auto *shortestPath = new nsTArray<nsCString>();
data = lBFSTable.Get(toMIMEType);
if (!data) {
// If this vertex isn't in the BFSTable, then no-one has registered for it,
// therefore we can't do the conversion.
delete shortestPath;
return NS_ERROR_FAILURE;
}
while (data) {
if (fromStr.Equals(data->key)) {
// found it. We're done here.
*aEdgeList = shortestPath;
return NS_OK;
}
// reconstruct the CONTRACTID.
// Get the predecessor.
if (!data->predecessor) break; // no predecessor
BFSTableData *predecessorData = lBFSTable.Get(*data->predecessor);
if (!predecessorData) break; // no predecessor, chain doesn't exist.
// build out the CONTRACTID.
nsAutoCString newContractID(ContractIDPrefix);
newContractID.AppendLiteral("?from=");
newContractID.Append(predecessorData->key);
newContractID.AppendLiteral("&to=");
newContractID.Append(data->key);
// Add this CONTRACTID to the chain.
rv = shortestPath->AppendElement(newContractID) ? NS_OK : NS_ERROR_FAILURE; // XXX this method incorrectly returns a bool
NS_ASSERTION(NS_SUCCEEDED(rv), "AppendElement failed");
// move up the tree.
data = predecessorData;
}
delete shortestPath;
return NS_ERROR_FAILURE; // couldn't find a stream converter or chain.
}
/////////////////////////////////////////////////////
// nsIStreamConverterService methods
NS_IMETHODIMP
nsStreamConverterService::CanConvert(const char* aFromType,
const char* aToType,
bool* _retval) {
nsCOMPtr<nsIComponentRegistrar> reg;
nsresult rv = NS_GetComponentRegistrar(getter_AddRefs(reg));
if (NS_FAILED(rv))
return rv;
nsAutoCString contractID;
contractID.AssignLiteral(NS_ISTREAMCONVERTER_KEY "?from=");
contractID.Append(aFromType);
contractID.AppendLiteral("&to=");
contractID.Append(aToType);
// See if we have a direct match
rv = reg->IsContractIDRegistered(contractID.get(), _retval);
if (NS_FAILED(rv))
return rv;
if (*_retval)
return NS_OK;
// Otherwise try the graph.
rv = BuildGraph();
if (NS_FAILED(rv))
return rv;
nsTArray<nsCString> *converterChain = nullptr;
rv = FindConverter(contractID.get(), &converterChain);
*_retval = NS_SUCCEEDED(rv);
delete converterChain;
return NS_OK;
}
NS_IMETHODIMP
nsStreamConverterService::Convert(nsIInputStream *aFromStream,
const char *aFromType,
const char *aToType,
nsISupports *aContext,
nsIInputStream **_retval) {
if (!aFromStream || !aFromType || !aToType || !_retval) return NS_ERROR_NULL_POINTER;
nsresult rv;
// first determine whether we can even handle this conversion
// build a CONTRACTID
nsAutoCString contractID;
contractID.AssignLiteral(NS_ISTREAMCONVERTER_KEY "?from=");
contractID.Append(aFromType);
contractID.AppendLiteral("&to=");
contractID.Append(aToType);
const char *cContractID = contractID.get();
nsCOMPtr<nsIStreamConverter> converter(do_CreateInstance(cContractID, &rv));
if (NS_FAILED(rv)) {
// couldn't go direct, let's try walking the graph of converters.
rv = BuildGraph();
if (NS_FAILED(rv)) return rv;
nsTArray<nsCString> *converterChain = nullptr;
rv = FindConverter(cContractID, &converterChain);
if (NS_FAILED(rv)) {
// can't make this conversion.
// XXX should have a more descriptive error code.
return NS_ERROR_FAILURE;
}
int32_t edgeCount = int32_t(converterChain->Length());
NS_ASSERTION(edgeCount > 0, "findConverter should have failed");
// convert the stream using each edge of the graph as a step.
// this is our stream conversion traversal.
nsCOMPtr<nsIInputStream> dataToConvert = aFromStream;
nsCOMPtr<nsIInputStream> convertedData;
for (int32_t i = edgeCount-1; i >= 0; i--) {
const char *lContractID = converterChain->ElementAt(i).get();
converter = do_CreateInstance(lContractID, &rv);
if (NS_FAILED(rv)) {
delete converterChain;
return rv;
}
nsAutoCString fromStr, toStr;
rv = ParseFromTo(lContractID, fromStr, toStr);
if (NS_FAILED(rv)) {
delete converterChain;
return rv;
}
rv = converter->Convert(dataToConvert, fromStr.get(), toStr.get(), aContext, getter_AddRefs(convertedData));
dataToConvert = convertedData;
if (NS_FAILED(rv)) {
delete converterChain;
return rv;
}
}
delete converterChain;
convertedData.forget(_retval);
} else {
// we're going direct.
rv = converter->Convert(aFromStream, aFromType, aToType, aContext, _retval);
}
return rv;
}
NS_IMETHODIMP
nsStreamConverterService::AsyncConvertData(const char *aFromType,
const char *aToType,
nsIStreamListener *aListener,
nsISupports *aContext,
nsIStreamListener **_retval) {
if (!aFromType || !aToType || !aListener || !_retval) return NS_ERROR_NULL_POINTER;
nsresult rv;
// first determine whether we can even handle this conversion
// build a CONTRACTID
nsAutoCString contractID;
contractID.AssignLiteral(NS_ISTREAMCONVERTER_KEY "?from=");
contractID.Append(aFromType);
contractID.AppendLiteral("&to=");
contractID.Append(aToType);
const char *cContractID = contractID.get();
nsCOMPtr<nsIStreamConverter> listener(do_CreateInstance(cContractID, &rv));
if (NS_FAILED(rv)) {
// couldn't go direct, let's try walking the graph of converters.
rv = BuildGraph();
if (NS_FAILED(rv)) return rv;
nsTArray<nsCString> *converterChain = nullptr;
rv = FindConverter(cContractID, &converterChain);
if (NS_FAILED(rv)) {
// can't make this conversion.
// XXX should have a more descriptive error code.
return NS_ERROR_FAILURE;
}
// aListener is the listener that wants the final, converted, data.
// we initialize finalListener w/ aListener so it gets put at the
// tail end of the chain, which in the loop below, means the *first*
// converter created.
nsCOMPtr<nsIStreamListener> finalListener = aListener;
// convert the stream using each edge of the graph as a step.
// this is our stream conversion traversal.
int32_t edgeCount = int32_t(converterChain->Length());
NS_ASSERTION(edgeCount > 0, "findConverter should have failed");
for (int i = 0; i < edgeCount; i++) {
const char *lContractID = converterChain->ElementAt(i).get();
// create the converter for this from/to pair
nsCOMPtr<nsIStreamConverter> converter(do_CreateInstance(lContractID));
NS_ASSERTION(converter, "graph construction problem, built a contractid that wasn't registered");
nsAutoCString fromStr, toStr;
rv = ParseFromTo(lContractID, fromStr, toStr);
if (NS_FAILED(rv)) {
delete converterChain;
return rv;
}
// connect the converter w/ the listener that should get the converted data.
rv = converter->AsyncConvertData(fromStr.get(), toStr.get(), finalListener, aContext);
if (NS_FAILED(rv)) {
delete converterChain;
return rv;
}
nsCOMPtr<nsIStreamListener> chainListener(do_QueryInterface(converter, &rv));
if (NS_FAILED(rv)) {
delete converterChain;
return rv;
}
// the last iteration of this loop will result in finalListener
// pointing to the converter that "starts" the conversion chain.
// this converter's "from" type is the original "from" type. Prior
// to the last iteration, finalListener will continuously be wedged
// into the next listener in the chain, then be updated.
finalListener = chainListener;
}
delete converterChain;
// return the first listener in the chain.
finalListener.forget(_retval);
} else {
// we're going direct.
rv = listener->AsyncConvertData(aFromType, aToType, aListener, aContext);
listener.forget(_retval);
}
return rv;
}
nsresult
NS_NewStreamConv(nsStreamConverterService** aStreamConv)
{
NS_PRECONDITION(aStreamConv != nullptr, "null ptr");
if (!aStreamConv) return NS_ERROR_NULL_POINTER;
*aStreamConv = new nsStreamConverterService();
NS_ADDREF(*aStreamConv);
return NS_OK;
}

View file

@ -0,0 +1,46 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef __nsstreamconverterservice__h___
#define __nsstreamconverterservice__h___
#include "nsIStreamConverterService.h"
#include "nsClassHashtable.h"
#include "nsCOMArray.h"
#include "nsTArrayForwardDeclare.h"
class nsCString;
class nsIAtom;
class nsStreamConverterService : public nsIStreamConverterService {
public:
/////////////////////////////////////////////////////
// nsISupports methods
NS_DECL_ISUPPORTS
/////////////////////////////////////////////////////
// nsIStreamConverterService methods
NS_DECL_NSISTREAMCONVERTERSERVICE
/////////////////////////////////////////////////////
// nsStreamConverterService methods
nsStreamConverterService();
private:
virtual ~nsStreamConverterService();
// Responsible for finding a converter for the given MIME-type.
nsresult FindConverter(const char *aContractID, nsTArray<nsCString> **aEdgeList);
nsresult BuildGraph(void);
nsresult AddAdjacency(const char *aContractID);
nsresult ParseFromTo(const char *aContractID, nsCString &aFromRes, nsCString &aToRes);
// member variables
nsClassHashtable<nsCStringHashKey, nsCOMArray<nsIAtom>> mAdjacencyList;
};
#endif // __nsstreamconverterservice__h___

View file

@ -0,0 +1,140 @@
#include "Converters.h"
#include "nsIStringStream.h"
#include "nsCOMPtr.h"
#include "nsComponentManagerUtils.h"
#include <stdio.h>
//////////////////////////////////////////////////
// TestConverter
//////////////////////////////////////////////////
#define NS_TESTCONVERTER_CID \
{ /* B8A067B0-4450-11d3-A16E-0050041CAF44 */ \
0xb8a067b0, \
0x4450, \
0x11d3, \
{0xa1, 0x6e, 0x00, 0x50, 0x04, 0x1c, 0xaf, 0x44} \
}
NS_DEFINE_CID(kTestConverterCID, NS_TESTCONVERTER_CID);
NS_IMPL_ISUPPORTS(TestConverter,
nsIStreamConverter,
nsIStreamListener,
nsIRequestObserver)
TestConverter::TestConverter() {
}
// Convert aFromStream (of type aFromType), to _retval (nsIInputStream of type aToType).
// This Convert method simply converts the stream byte-by-byte, to the first character
// in the aToType "string".
NS_IMETHODIMP
TestConverter::Convert(nsIInputStream *aFromStream,
const char *aFromType,
const char *aToType,
nsISupports *ctxt,
nsIInputStream **_retval) {
char buf[1024+1];
uint32_t read;
nsresult rv = aFromStream->Read(buf, 1024, &read);
if (NS_FAILED(rv) || read == 0) return rv;
// verify that the data we're converting matches the from type
// if it doesn't then we're being handed the wrong data.
char fromChar = *aFromType;
if (fromChar != buf[0]) {
printf("We're receiving %c, but are supposed to have %c.\n", buf[0], fromChar);
return NS_ERROR_FAILURE;
}
// Get the first character
char toChar = *aToType;
for (uint32_t i = 0; i < read; i++)
buf[i] = toChar;
buf[read] = '\0';
nsCOMPtr<nsIStringInputStream> str
(do_CreateInstance("@mozilla.org/io/string-input-stream;1", &rv));
NS_ENSURE_SUCCESS(rv, rv);
rv = str->SetData(buf, read);
NS_ENSURE_SUCCESS(rv, rv);
NS_ADDREF(*_retval = str);
return NS_OK;
}
/* This method initializes any internal state before the stream converter
* begins asynchronous conversion */
NS_IMETHODIMP
TestConverter::AsyncConvertData(const char *aFromType,
const char *aToType,
nsIStreamListener *aListener,
nsISupports *ctxt) {
NS_ASSERTION(aListener, "null listener");
mListener = aListener;
// based on these types, setup internal state to handle the appropriate conversion.
fromType = aFromType;
toType = aToType;
return NS_OK;
}
// nsIStreamListener method
/* This method handles asyncronous conversion of data. */
NS_IMETHODIMP
TestConverter::OnDataAvailable(nsIRequest* request,
nsISupports *ctxt,
nsIInputStream *inStr,
uint64_t sourceOffset,
uint32_t count) {
nsresult rv;
nsCOMPtr<nsIInputStream> convertedStream;
// just make a syncronous call to the Convert() method.
// Anything can happen here, I just happen to be using the sync call to
// do the actual conversion.
rv = Convert(inStr, fromType.get(), toType.get(), ctxt, getter_AddRefs(convertedStream));
if (NS_FAILED(rv)) return rv;
uint64_t len = 0;
convertedStream->Available(&len);
uint64_t offset = sourceOffset;
while (len > 0) {
uint32_t count = saturated(len);
rv = mListener->OnDataAvailable(request, ctxt, convertedStream, offset, count);
if (NS_FAILED(rv)) return rv;
offset += count;
len -= count;
}
return NS_OK;
}
// nsIRequestObserver methods
/* These methods just pass through directly to the mListener */
NS_IMETHODIMP
TestConverter::OnStartRequest(nsIRequest* request, nsISupports *ctxt) {
return mListener->OnStartRequest(request, ctxt);
}
NS_IMETHODIMP
TestConverter::OnStopRequest(nsIRequest* request, nsISupports *ctxt,
nsresult aStatus) {
return mListener->OnStopRequest(request, ctxt, aStatus);
}
nsresult
CreateTestConverter(nsISupports* aOuter, REFNSIID aIID, void** aResult)
{
nsCOMPtr<nsISupports> conv = new TestConverter();
return conv->QueryInterface(aIID, aResult);
}

View file

@ -0,0 +1,52 @@
#ifndef Converters_h___
#define Converters_h___
#include "nsIStreamConverter.h"
#include "nsIFactory.h"
#include "nsCOMPtr.h"
#include "nsStringAPI.h"
#include <algorithm>
/* This file defines stream converter components, and their accompanying factory class.
* These converters implement the nsIStreamConverter interface and support both
* asynchronous and synchronous stream conversion.
*/
///////////////////////////////////////////////
// TestConverter
extern const nsCID kTestConverterCID;
class TestConverter : public nsIStreamConverter {
virtual ~TestConverter() {}
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIREQUESTOBSERVER
NS_DECL_NSISTREAMLISTENER
TestConverter();
// nsIStreamConverter methods
NS_IMETHOD Convert(nsIInputStream *aFromStream, const char *aFromType,
const char *aToType, nsISupports *ctxt, nsIInputStream **_retval) override;
NS_IMETHOD AsyncConvertData(const char *aFromType, const char *aToType,
nsIStreamListener *aListener, nsISupports *ctxt) override;
// member data
nsCOMPtr<nsIStreamListener> mListener;
nsCString fromType;
nsCString toType;
};
nsresult CreateTestConverter(nsISupports* aOuter, REFNSIID aIID, void** aResult);
static inline uint32_t
saturated(uint64_t aValue)
{
return (uint32_t) std::min(aValue, (uint64_t) UINT32_MAX);
}
#endif /* !Converters_h___ */

View file

@ -0,0 +1,261 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsIServiceManager.h"
#include "nsIStreamConverterService.h"
#include "nsIStreamConverter.h"
#include "nsICategoryManager.h"
#include "mozilla/Module.h"
#include "nsXULAppAPI.h"
#include "nsIStringStream.h"
#include "nsCOMPtr.h"
#include "nsThreadUtils.h"
#include "mozilla/Attributes.h"
#include "nsMemory.h"
#include "nsServiceManagerUtils.h"
#include "nsComponentManagerUtils.h"
#include "nsIRequest.h"
#include "nsNetCID.h"
#include "nsNetUtil.h"
#define ASYNC_TEST // undefine this if you want to test sycnronous conversion.
/////////////////////////////////
// Event pump setup
/////////////////////////////////
#ifdef XP_WIN
#include <windows.h>
#endif
static int gKeepRunning = 0;
/////////////////////////////////
// Event pump END
/////////////////////////////////
/////////////////////////////////
// Test converters include
/////////////////////////////////
#include "Converters.h"
// CID setup
static NS_DEFINE_CID(kStreamConverterServiceCID, NS_STREAMCONVERTERSERVICE_CID);
////////////////////////////////////////////////////////////////////////
// EndListener - This listener is the final one in the chain. It
// receives the fully converted data, although it doesn't do anything with
// the data.
////////////////////////////////////////////////////////////////////////
class EndListener final : public nsIStreamListener {
~EndListener() {}
public:
// nsISupports declaration
NS_DECL_ISUPPORTS
EndListener() {}
// nsIStreamListener method
NS_IMETHOD OnDataAvailable(nsIRequest* request, nsISupports *ctxt, nsIInputStream *inStr,
uint64_t sourceOffset, uint32_t count) override
{
nsresult rv;
uint32_t read;
uint64_t len64;
rv = inStr->Available(&len64);
if (NS_FAILED(rv)) return rv;
uint32_t len = (uint32_t)std::min(len64, (uint64_t)(UINT32_MAX - 1));
char *buffer = (char*)moz_xmalloc(len + 1);
if (!buffer) return NS_ERROR_OUT_OF_MEMORY;
rv = inStr->Read(buffer, len, &read);
buffer[len] = '\0';
if (NS_SUCCEEDED(rv)) {
printf("CONTEXT %p: Received %u bytes and the following data: \n %s\n\n",
static_cast<void*>(ctxt), read, buffer);
}
free(buffer);
return NS_OK;
}
// nsIRequestObserver methods
NS_IMETHOD OnStartRequest(nsIRequest* request, nsISupports *ctxt) override { return NS_OK; }
NS_IMETHOD OnStopRequest(nsIRequest* request, nsISupports *ctxt,
nsresult aStatus) override { return NS_OK; }
};
NS_IMPL_ISUPPORTS(EndListener,
nsIStreamListener,
nsIRequestObserver)
////////////////////////////////////////////////////////////////////////
// EndListener END
////////////////////////////////////////////////////////////////////////
nsresult SendData(const char * aData, nsIStreamListener* aListener, nsIRequest* request) {
nsresult rv;
nsCOMPtr<nsIStringInputStream> dataStream
(do_CreateInstance("@mozilla.org/io/string-input-stream;1", &rv));
NS_ENSURE_SUCCESS(rv, rv);
rv = dataStream->SetData(aData, strlen(aData));
NS_ENSURE_SUCCESS(rv, rv);
uint64_t avail = 0;
dataStream->Available(&avail);
uint64_t offset = 0;
while (avail > 0) {
uint32_t count = saturated(avail);
rv = aListener->OnDataAvailable(request, nullptr, dataStream,
offset, count);
if (NS_FAILED(rv)) return rv;
offset += count;
avail -= count;
}
return NS_OK;
}
#define SEND_DATA(x) SendData(x, converterListener, request)
static const mozilla::Module::CIDEntry kTestCIDs[] = {
{ &kTestConverterCID, false, nullptr, CreateTestConverter },
{ nullptr }
};
static const mozilla::Module::ContractIDEntry kTestContracts[] = {
{ NS_ISTREAMCONVERTER_KEY "?from=a/foo&to=b/foo", &kTestConverterCID },
{ NS_ISTREAMCONVERTER_KEY "?from=b/foo&to=c/foo", &kTestConverterCID },
{ NS_ISTREAMCONVERTER_KEY "?from=b/foo&to=d/foo", &kTestConverterCID },
{ NS_ISTREAMCONVERTER_KEY "?from=c/foo&to=d/foo", &kTestConverterCID },
{ NS_ISTREAMCONVERTER_KEY "?from=d/foo&to=e/foo", &kTestConverterCID },
{ NS_ISTREAMCONVERTER_KEY "?from=d/foo&to=f/foo", &kTestConverterCID },
{ NS_ISTREAMCONVERTER_KEY "?from=t/foo&to=k/foo", &kTestConverterCID },
{ nullptr }
};
static const mozilla::Module::CategoryEntry kTestCategories[] = {
{ NS_ISTREAMCONVERTER_KEY, "?from=a/foo&to=b/foo", "x" },
{ NS_ISTREAMCONVERTER_KEY, "?from=b/foo&to=c/foo", "x" },
{ NS_ISTREAMCONVERTER_KEY, "?from=b/foo&to=d/foo", "x" },
{ NS_ISTREAMCONVERTER_KEY, "?from=c/foo&to=d/foo", "x" },
{ NS_ISTREAMCONVERTER_KEY, "?from=d/foo&to=e/foo", "x" },
{ NS_ISTREAMCONVERTER_KEY, "?from=d/foo&to=f/foo", "x" },
{ NS_ISTREAMCONVERTER_KEY, "?from=t/foo&to=k/foo", "x" },
{ nullptr }
};
static const mozilla::Module kTestModule = {
mozilla::Module::kVersion,
kTestCIDs,
kTestContracts,
kTestCategories
};
int
main(int argc, char* argv[])
{
nsresult rv;
{
XRE_AddStaticComponent(&kTestModule);
nsCOMPtr<nsIServiceManager> servMan;
NS_InitXPCOM2(getter_AddRefs(servMan), nullptr, nullptr);
nsCOMPtr<nsIThread> thread = do_GetCurrentThread();
nsCOMPtr<nsICategoryManager> catman =
do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv);
if (NS_FAILED(rv)) return -1;
nsCString previous;
nsCOMPtr<nsIStreamConverterService> StreamConvService =
do_GetService(kStreamConverterServiceCID, &rv);
if (NS_FAILED(rv)) return -1;
// Define the *from* content type and *to* content-type for conversion.
static const char fromStr[] = "a/foo";
static const char toStr[] = "c/foo";
#ifdef ASYNC_TEST
// ASYNCHRONOUS conversion
// Build up a channel that represents the content we're
// starting the transaction with.
//
// sample multipart mixed content-type string:
// "multipart/x-mixed-replacE;boundary=thisrandomstring"
#if 0
nsCOMPtr<nsIChannel> channel;
nsCOMPtr<nsIURI> dummyURI;
rv = NS_NewURI(getter_AddRefs(dummyURI), "http://meaningless");
if (NS_FAILED(rv)) return -1;
rv = NS_NewInputStreamChannel(getter_AddRefs(channel),
dummyURI,
nullptr, // inStr
"text/plain", // content-type
-1); // XXX fix contentLength
if (NS_FAILED(rv)) return -1;
nsCOMPtr<nsIRequest> request(do_QueryInterface(channel));
#endif
nsCOMPtr<nsIRequest> request;
// setup a listener to receive the converted data. This guy is the end
// listener in the chain, he wants the fully converted (toType) data.
// An example of this listener in mozilla would be the DocLoader.
nsIStreamListener *dataReceiver = new EndListener();
NS_ADDREF(dataReceiver);
// setup a listener to push the data into. This listener sits inbetween the
// unconverted data of fromType, and the final listener in the chain (in this case
// the dataReceiver.
nsIStreamListener *converterListener = nullptr;
rv = StreamConvService->AsyncConvertData(fromStr, toStr,
dataReceiver, nullptr, &converterListener);
if (NS_FAILED(rv)) return -1;
NS_RELEASE(dataReceiver);
// at this point we have a stream listener to push data to, and the one
// that will receive the converted data. Let's mimic On*() calls and get the conversion
// going. Typically these On*() calls would be made inside their respective wrappers On*()
// methods.
rv = converterListener->OnStartRequest(request, nullptr);
if (NS_FAILED(rv)) return -1;
rv = SEND_DATA("aaa");
if (NS_FAILED(rv)) return -1;
rv = SEND_DATA("aaa");
if (NS_FAILED(rv)) return -1;
// Finish the request.
rv = converterListener->OnStopRequest(request, nullptr, rv);
if (NS_FAILED(rv)) return -1;
NS_RELEASE(converterListener);
#else
// SYNCHRONOUS conversion
nsCOMPtr<nsIInputStream> convertedData;
rv = StreamConvService->Convert(inputData, fromStr, toStr,
nullptr, getter_AddRefs(convertedData));
if (NS_FAILED(rv)) return -1;
#endif
// Enter the message pump to allow the URL load to proceed.
while ( gKeepRunning ) {
if (!NS_ProcessNextEvent(thread))
break;
}
} // this scopes the nsCOMPtrs
// no nsCOMPtrs are allowed to be alive when you call NS_ShutdownXPCOM
NS_ShutdownXPCOM(nullptr);
return 0;
}

View file

@ -0,0 +1,22 @@
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
GeckoProgram('TestStreamConv', linkage='dependent')
UNIFIED_SOURCES += [
'Converters.cpp',
'TestStreamConv.cpp',
]
if CONFIG['OS_ARCH'] == 'WINNT':
DEFINES['NGPREFS'] = True
if CONFIG['GNU_CXX']:
LDFLAGS += ['-mconsole']
else:
LDFLAGS += ['-SUBSYSTEM:CONSOLE']
if CONFIG['GNU_CXX']:
CXXFLAGS += ['-Wno-error=shadow']