Part of fix for nsbeta2+ bug # 28787: FTP listings of non-ascii filenames. r=gagan

This commit is contained in:
rjc%netscape.com 2000-07-14 23:21:48 +00:00
Родитель 7ed087c304
Коммит b28d5acd85
2 изменённых файлов: 35 добавлений и 14 удалений

Просмотреть файл

@ -39,9 +39,6 @@ function Init()
{
debug("directory.js: Init()\n");
// Add the HTTPIndex datasource into the tree
var tree = document.getElementById('tree');
// Initialize the tree's base URL to whatever the HTTPIndex is rooted at
var baseURI = HTTPIndex.BaseURL;
@ -54,11 +51,26 @@ function Init()
baseURI += "/";
}
debug("base URL = " + baseURI + "\n");
// Note: set encoding for FTP URLs BEFORE setting "ref"
HTTPIndex.encoding = "ISO-8859-1";
// re-root the tree
// Note: Add the HTTPIndex datasource into the tree
var tree = document.getElementById('tree');
// Note: set encoding BEFORE setting "ref" (important!)
var RDF = Components.classes["component://netscape/rdf/rdf-service"].getService();
if (RDF) RDF = RDF.QueryInterface(Components.interfaces.nsIRDFService);
if (RDF)
{
var httpDS = RDF.GetDataSource("rdf:httpindex");
if (httpDS) httpDS = httpDS.QueryInterface(Components.interfaces.nsIHTTPIndex);
if (httpDS)
{
// TO DO - The encoding should really be determined
// from the current encoding as chosen by the user
httpDS.encoding = "ISO-8859-1";
}
}
// root the tree (do this last)
tree.setAttribute("ref", baseURI);
}

Просмотреть файл

@ -682,7 +682,13 @@ nsHTTPIndexParser::ParseData(const char* aDataStr, nsISupports *context)
rv = NS_OK;
nsCOMPtr<nsIRDFResource> entry;
nsCAutoString filename, filetype;
nsCAutoString filename, filetype;
nsXPIDLCString encodingStr;
if (mHTTPIndex)
{
mHTTPIndex->GetEncoding(getter_Copies(encodingStr));
}
for (PRInt32 i = 0; i < mFormat.Count(); ++i) {
// If we've exhausted the data before we run out of fields, just
@ -732,12 +738,15 @@ nsHTTPIndexParser::ParseData(const char* aDataStr, nsISupports *context)
if (textToSubURI)
{
PRUnichar *result = nsnull;
if (NS_SUCCEEDED(rv = textToSubURI->UnEscapeAndConvert("EUC-JP", filename,
&result)) && (result) && (nsCRT::strlen(result) > 0))
if (NS_SUCCEEDED(rv = textToSubURI->UnEscapeAndConvert(encodingStr, filename,
&result)) && (result))
{
values[i].Append(result);
if (nsCRT::strlen(result) > 0)
{
values[i].Append(result);
success = PR_TRUE;
}
Recycle(result);
success = PR_TRUE;
}
else
{
@ -747,7 +756,8 @@ nsHTTPIndexParser::ParseData(const char* aDataStr, nsISupports *context)
if (success == PR_FALSE)
{
// unescape the nsStr (in place)
// if unsuccessfully at charset conversion, then
// just fallback to unescape'ing the nsStr (in place)
value.mLength = nsUnescapeCount(value.mStr);
values[i].AppendWithConversion(value);
}
@ -769,7 +779,6 @@ nsHTTPIndexParser::ParseData(const char* aDataStr, nsISupports *context)
// we found the filename; construct a resource for its entry
nsAutoString entryuri;
nsXPIDLCString encodingStr;
rv = NS_MakeAbsoluteURI(entryuri, NS_ConvertASCIItoUCS2(filename), realbase);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable make absolute URI");