Changed to make string as array so sizeof returns number of characters instead of a size of a pointer,

this fixes a wrong offset problem for parsing charset, bug 80114, r=attinasi, sr=blizzard.
This commit is contained in:
nhotta%netscape.com 2001-05-15 03:03:19 +00:00
parent 1d120d9e17
commit f023e39b47
2 changed files with 8 additions and 8 deletions

View File

@ -1619,17 +1619,17 @@ nsresult CSSLoaderImpl::SetCharset(/*in*/ const nsString &aHTTPHeader,
if (aHTTPHeader.Length() > 0) {
// check if it has the charset= parameter
PRInt32 charsetOffset;
static const char* charsetStr = "charset=";
static const char charsetStr[] = "charset=";
if ((charsetOffset = aHTTPHeader.Find(charsetStr,PR_TRUE)) > 0) {
aHTTPHeader.Mid(str, charsetOffset + sizeof(charsetStr), -1);
aHTTPHeader.Mid(str, charsetOffset + sizeof(charsetStr)-1, -1);
setCharset = PR_TRUE;
}
} else if (aStyleSheetData.Length() > 0) {
static const char* atCharsetStr = "@charset";
static const char atCharsetStr[] = "@charset";
if (aStyleSheetData.Find(atCharsetStr) > -1) {
nsString strValue;
// skip past the ident
aStyleSheetData.Mid(str,sizeof(atCharsetStr),-1);
aStyleSheetData.Mid(str,sizeof(atCharsetStr)-1,-1);
// strip any whitespace
str.StripWhitespace();
// truncate everything past the delimiter (semicolon)

View File

@ -1619,17 +1619,17 @@ nsresult CSSLoaderImpl::SetCharset(/*in*/ const nsString &aHTTPHeader,
if (aHTTPHeader.Length() > 0) {
// check if it has the charset= parameter
PRInt32 charsetOffset;
static const char* charsetStr = "charset=";
static const char charsetStr[] = "charset=";
if ((charsetOffset = aHTTPHeader.Find(charsetStr,PR_TRUE)) > 0) {
aHTTPHeader.Mid(str, charsetOffset + sizeof(charsetStr), -1);
aHTTPHeader.Mid(str, charsetOffset + sizeof(charsetStr)-1, -1);
setCharset = PR_TRUE;
}
} else if (aStyleSheetData.Length() > 0) {
static const char* atCharsetStr = "@charset";
static const char atCharsetStr[] = "@charset";
if (aStyleSheetData.Find(atCharsetStr) > -1) {
nsString strValue;
// skip past the ident
aStyleSheetData.Mid(str,sizeof(atCharsetStr),-1);
aStyleSheetData.Mid(str,sizeof(atCharsetStr)-1,-1);
// strip any whitespace
str.StripWhitespace();
// truncate everything past the delimiter (semicolon)