Comment 78 for bug 222635

Revision history for this message
In , Michal-novotny (michal-novotny) wrote :

Comment on attachment 570960
Part 3. FTP directory list sets the encoding when current FTP server supports UTF-8 v2

> + channel->GetContentCharset(mCharset);
> + if (mCharset.EqualsLiteral("UTF-8")) {
> + // For RFC 2640 support, charset is into HTML, not channel.
> + // So we need clear charset on channel.
> + channel->SetContentCharset(NS_LITERAL_CSTRING(""));
> + }

Could you please make the comment more verbose? Why it is needed to clear the charset and why only in case of UTF8?

> + if (mCharset.EqualsLiteral("UTF-8") && !IsUTF8(mPendingBuffer)) {
> + // RFC 2640 section 3.3 says the following.
> + //
> + // If a client detects that a server is non UTF-8,
> + // it SHOULD change its display appropriately.
> + //
> + // So we need failback encoding.
> + mCharset.AssignLiteral("ISO-8859-1");
> + }

There is still a problem when the directory is empty and its name isn't a valid UTF8 string. In this case call to mTextToSubURI->UnEscapeAndConvert() in nsIndexedToHTML::OnHeaderAvailable() fails.