зеркало из https://github.com/mozilla/gecko-dev.git
Bug 118438 Gopher 'information' tag not supported.
patch by Jan Ruzicka <jan.ruzicka@comcast.net> r=biesi sr=darin
This commit is contained in:
Родитель
8a94f429b0
Коммит
4b89aaa53e
|
@ -430,6 +430,11 @@ nsDirIndexParser::ProcessData(nsIRequest *aRequest, nsISupports *aCtxt) {
|
|||
} 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);
|
||||
|
|
|
@ -303,12 +303,16 @@ nsGopherDirListingConv::DigestBufferLines(char* aBuffer, nsCAutoString& aString)
|
|||
|
||||
/* Get the description */
|
||||
if (tabPos) {
|
||||
char* descStr = PL_strndup(line,tabPos-line);
|
||||
char* escName = nsEscape(descStr,url_Path);
|
||||
desc = escName;
|
||||
nsMemory::Free(escName);
|
||||
nsMemory::Free(descStr);
|
||||
|
||||
/* if the description is not empty */
|
||||
if (tabPos != line) {
|
||||
char* descStr = PL_strndup(line,tabPos-line);
|
||||
char* escName = nsEscape(descStr,url_Path);
|
||||
desc = escName;
|
||||
nsMemory::Free(escName);
|
||||
nsMemory::Free(descStr);
|
||||
} else {
|
||||
desc = "%20";
|
||||
}
|
||||
line = tabPos+1;
|
||||
tabPos = PL_strchr(line,'\t');
|
||||
}
|
||||
|
@ -390,6 +394,10 @@ nsGopherDirListingConv::DigestBufferLines(char* aBuffer, nsCAutoString& aString)
|
|||
else
|
||||
aString.Append("FILE");
|
||||
aString.Append(char(nsCRT::LF));
|
||||
} else if(type == 'i'){
|
||||
aString.Append("101: ");
|
||||
aString.Append(desc);
|
||||
aString.Append(char(nsCRT::LF));
|
||||
}
|
||||
} else {
|
||||
NS_WARNING("Error parsing gopher directory response.\n");
|
||||
|
|
|
@ -598,6 +598,28 @@ nsIndexedToHTML::OnIndexAvailable(nsIRequest *aRequest,
|
|||
return FormatInputStream(aRequest, aCtxt, pushBuffer);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsIndexedToHTML::OnInformationAvailable(nsIRequest *aRequest,
|
||||
nsISupports *aCtxt,
|
||||
const nsAString& aInfo) {
|
||||
nsAutoString pushBuffer;
|
||||
PRUnichar* escaped = nsEscapeHTML2(PromiseFlatString(aInfo).get());
|
||||
if (!escaped)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
pushBuffer.Append(NS_LITERAL_STRING("<tr>\n <td>"));
|
||||
pushBuffer.Append(escaped);
|
||||
nsMemory::Free(escaped);
|
||||
pushBuffer.Append(NS_LITERAL_STRING("</td>\n <td></td>\n <td></td>\n <td></td>\n</tr>\n"));
|
||||
|
||||
// Split this up to avoid slow layout performance with large tables
|
||||
// - bug 85381
|
||||
if (++mRowCount > ROWS_PER_TABLE) {
|
||||
pushBuffer.Append(NS_LITERAL_STRING("</table>\n<table>\n"));
|
||||
mRowCount = 0;
|
||||
}
|
||||
return FormatInputStream(aRequest, aCtxt, pushBuffer);
|
||||
}
|
||||
|
||||
void nsIndexedToHTML::FormatSizeString(PRInt64 inSize, nsString& outSizeString)
|
||||
{
|
||||
nsInt64 size(inSize);
|
||||
|
|
|
@ -57,6 +57,18 @@ interface nsIDirIndexListener : nsISupports {
|
|||
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++
|
||||
|
|
|
@ -543,6 +543,13 @@ nsHTTPIndex::OnIndexAvailable(nsIRequest* aRequest, nsISupports *aContext,
|
|||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsHTTPIndex::OnInformationAvailable(nsIRequest *aRequest,
|
||||
nsISupports *aCtxt,
|
||||
const nsAString& aInfo) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
//
|
||||
// nsHTTPIndex implementation
|
||||
|
|
Загрузка…
Ссылка в новой задаче