зеркало из https://github.com/mozilla/gecko-dev.git
bug 91696, Meta tag does not work, r=shanjian , sr=vidur
This commit is contained in:
Родитель
8d64a0247b
Коммит
41bf2e10fe
|
@ -2520,7 +2520,7 @@ nsParser::DetectMetaTag(const char* aBytes,
|
||||||
if ((offset = tokenizer.GetNextWord(PR_TRUE)) != kNotFound) {
|
if ((offset = tokenizer.GetNextWord(PR_TRUE)) != kNotFound) {
|
||||||
const char* contentStart = attrStart+offset;
|
const char* contentStart = attrStart+offset;
|
||||||
CWordTokenizer<char> contentTokenizer(contentStart, 0,
|
CWordTokenizer<char> contentTokenizer(contentStart, 0,
|
||||||
tokenizer.GetLength());
|
attrEnd-contentStart);
|
||||||
|
|
||||||
// Read the content type
|
// Read the content type
|
||||||
if (contentTokenizer.GetNextWord() != kNotFound) {
|
if (contentTokenizer.GetNextWord() != kNotFound) {
|
||||||
|
|
|
@ -179,12 +179,16 @@ NS_IMETHODIMP nsMetaCharsetObserver::Notify(
|
||||||
PRInt32 i;
|
PRInt32 i;
|
||||||
const PRUnichar *httpEquivValue=nsnull;
|
const PRUnichar *httpEquivValue=nsnull;
|
||||||
const PRUnichar *contentValue=nsnull;
|
const PRUnichar *contentValue=nsnull;
|
||||||
|
const PRUnichar *charsetValue=nsnull;
|
||||||
|
|
||||||
for(i=0;i<(numOfAttributes-3);i++)
|
for(i=0;i<(numOfAttributes-3);i++)
|
||||||
{
|
{
|
||||||
if(0 == nsCRT::strcasecmp((keys->StringAt(i))->get(), "HTTP-EQUIV"))
|
if(0 == nsCRT::strcasecmp((keys->StringAt(i))->get(), "HTTP-EQUIV"))
|
||||||
httpEquivValue=((values->StringAt(i))->get());
|
httpEquivValue=((values->StringAt(i))->get());
|
||||||
else if(0 == nsCRT::strcasecmp((keys->StringAt(i))->get(), "content"))
|
else if(0 == nsCRT::strcasecmp((keys->StringAt(i))->get(), "content"))
|
||||||
contentValue=(values->StringAt(i))->get();
|
contentValue=(values->StringAt(i))->get();
|
||||||
|
else if(0 == nsCRT::strcasecmp((keys->StringAt(i))->get(), "charset"))
|
||||||
|
charsetValue=(values->StringAt(i))->get();
|
||||||
}
|
}
|
||||||
NS_NAMED_LITERAL_STRING(contenttype, "Content-Type");
|
NS_NAMED_LITERAL_STRING(contenttype, "Content-Type");
|
||||||
NS_NAMED_LITERAL_STRING(texthtml, "text/html");
|
NS_NAMED_LITERAL_STRING(texthtml, "text/html");
|
||||||
|
@ -212,6 +216,11 @@ NS_IMETHODIMP nsMetaCharsetObserver::Notify(
|
||||||
texthtml.Length()))
|
texthtml.Length()))
|
||||||
))
|
))
|
||||||
)
|
)
|
||||||
|
{
|
||||||
|
|
||||||
|
nsAutoString newCharset;
|
||||||
|
|
||||||
|
if (nsnull == charsetValue)
|
||||||
{
|
{
|
||||||
nsAutoString contentPart1(contentValue+10); // after "text/html;"
|
nsAutoString contentPart1(contentValue+10); // after "text/html;"
|
||||||
PRInt32 start = contentPart1.RFind("charset=", PR_TRUE ) ;
|
PRInt32 start = contentPart1.RFind("charset=", PR_TRUE ) ;
|
||||||
|
@ -221,10 +230,18 @@ NS_IMETHODIMP nsMetaCharsetObserver::Notify(
|
||||||
PRInt32 end = contentPart1.FindCharInSet("\'\";", start );
|
PRInt32 end = contentPart1.FindCharInSet("\'\";", start );
|
||||||
if(kNotFound == end )
|
if(kNotFound == end )
|
||||||
end = contentPart1.Length();
|
end = contentPart1.Length();
|
||||||
nsAutoString newCharset;
|
|
||||||
NS_ASSERTION(end>=start, "wrong index");
|
NS_ASSERTION(end>=start, "wrong index");
|
||||||
contentPart1.Mid(newCharset, start, end - start);
|
contentPart1.Mid(newCharset, start, end - start);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
newCharset = charsetValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (!newCharset.IsEmpty())
|
||||||
|
{
|
||||||
nsAutoString charsetString(charset);
|
nsAutoString charsetString(charset);
|
||||||
if(! newCharset.EqualsIgnoreCase(charsetString))
|
if(! newCharset.EqualsIgnoreCase(charsetString))
|
||||||
{
|
{
|
||||||
|
@ -248,7 +265,7 @@ NS_IMETHODIMP nsMetaCharsetObserver::Notify(
|
||||||
} // if(NS_SUCCEEDED(res)
|
} // if(NS_SUCCEEDED(res)
|
||||||
}
|
}
|
||||||
} // if EqualIgnoreCase
|
} // if EqualIgnoreCase
|
||||||
} // if (kNotFound != start)
|
} // if !newCharset.IsEmpty()
|
||||||
} // if
|
} // if
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -2520,7 +2520,7 @@ nsParser::DetectMetaTag(const char* aBytes,
|
||||||
if ((offset = tokenizer.GetNextWord(PR_TRUE)) != kNotFound) {
|
if ((offset = tokenizer.GetNextWord(PR_TRUE)) != kNotFound) {
|
||||||
const char* contentStart = attrStart+offset;
|
const char* contentStart = attrStart+offset;
|
||||||
CWordTokenizer<char> contentTokenizer(contentStart, 0,
|
CWordTokenizer<char> contentTokenizer(contentStart, 0,
|
||||||
tokenizer.GetLength());
|
attrEnd-contentStart);
|
||||||
|
|
||||||
// Read the content type
|
// Read the content type
|
||||||
if (contentTokenizer.GetNextWord() != kNotFound) {
|
if (contentTokenizer.GetNextWord() != kNotFound) {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче