Commit 75691022 authored by eseidel's avatar eseidel

Bug #: 6345

Submitted by: eseidel
Reviewed by: darin
        REGRESSION: repro crash w/ invalid charset attribute on <script>
        http://bugzilla.opendarwin.org/show_bug.cgi?id=6345
        I also made some small spacing cleanup here.
        I did *not* fix the usage in formData, as the move from KCharSet to
        QTextCodec actually fixed a bug whereby if the first listed charset
        in accept-charsets was invalid, we would assume latin1 instead of
        checking for the next valid one before assuming system encoding.

        * khtml/html/html_formimpl.cpp:
        (DOM::HTMLFormElementImpl::formData): cleanup
        * khtml/misc/loader.cpp:
        (CachedCSSStyleSheet::CachedCSSStyleSheet): null check
        (CachedScript::CachedScript): cleanup
        (CachedXSLStyleSheet::CachedXSLStyleSheet): null check
        (CachedXBLDocument::CachedXBLDocument): cleanup


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@11861 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 07bc085c
2006-01-03 Eric Seidel <eseidel@apple.com>
Reviewed by darin.
REGRESSION: repro crash w/ invalid charset attribute on <script>
http://bugzilla.opendarwin.org/show_bug.cgi?id=6345
I also made some small spacing cleanup here.
I did *not* fix the usage in formData, as the move from KCharSet to
QTextCodec actually fixed a bug whereby if the first listed charset
in accept-charsets was invalid, we would assume latin1 instead of
checking for the next valid one before assuming system encoding.
* khtml/html/html_formimpl.cpp:
(DOM::HTMLFormElementImpl::formData): cleanup
* khtml/misc/loader.cpp:
(CachedCSSStyleSheet::CachedCSSStyleSheet): null check
(CachedScript::CachedScript): cleanup
(CachedXSLStyleSheet::CachedXSLStyleSheet): null check
(CachedXBLDocument::CachedXBLDocument): cleanup
2006-01-03 Justin Garcia <justin.garcia@apple.com>
<http://bugzilla.opendarwin.org/show_bug.cgi?id=4904>
......
......@@ -307,21 +307,19 @@ bool HTMLFormElementImpl::formData(FormData &form_data) const
QStringList charsets = QStringList::split(' ', str);
QTextCodec* codec = 0;
KHTMLPart *part = getDocument()->part();
for ( QStringList::Iterator it = charsets.begin(); it != charsets.end(); ++it )
{
for (QStringList::Iterator it = charsets.begin(); it != charsets.end(); ++it) {
QString enc = (*it);
if(enc.contains("UNKNOWN"))
{
if (enc.contains("UNKNOWN")) {
// use standard document encoding
enc = "ISO-8859-1";
if (part)
enc = part->encoding();
}
if((codec = QTextCodec::codecForName(enc.latin1())))
if ((codec = QTextCodec::codecForName(enc.latin1())))
break;
}
if(!codec)
if (!codec)
codec = QTextCodec::codecForLocale();
......
......@@ -160,16 +160,16 @@ void CachedObject::setSize(int size)
// -------------------------------------------------------------------------------------------
CachedCSSStyleSheet::CachedCSSStyleSheet(DocLoader* dl, const DOMString &url, KIO::CacheControl _cachePolicy, time_t _expireDate, const QString& charset)
: CachedObject(url, CSSStyleSheet, _cachePolicy, _expireDate)
: CachedObject(url, CSSStyleSheet, _cachePolicy, _expireDate), m_codec(0)
{
// It's css we want.
setAccept( QString::fromLatin1("text/css") );
setAccept("text/css");
// load the file
Cache::loader()->load(dl, this, false);
m_loading = true;
if(!charset.isEmpty())
if (!charset.isEmpty())
m_codec = QTextCodec::codecForName(charset.latin1());
else
if (!m_codec)
m_codec = QTextCodec::codecForName("iso8859-1");
}
......@@ -247,19 +247,19 @@ void CachedCSSStyleSheet::error( int /*err*/, const char */*text*/ )
// -------------------------------------------------------------------------------------------
CachedScript::CachedScript(DocLoader* dl, const DOMString &url, KIO::CacheControl _cachePolicy, time_t _expireDate, const QString& charset)
: CachedObject(url, Script, _cachePolicy, _expireDate)
: CachedObject(url, Script, _cachePolicy, _expireDate), m_codec(0)
{
// It's javascript we want.
// But some websites think their scripts are <some wrong mimetype here>
// and refuse to serve them if we only accept application/x-javascript.
setAccept( QString::fromLatin1("*/*") );
setAccept("*/*");
m_errorOccurred = false;
// load the file
Cache::loader()->load(dl, this, false);
m_loading = true;
if(!charset.isEmpty())
if (!charset.isEmpty())
m_codec = QTextCodec::codecForName(charset.latin1());
else
if (!m_codec)
m_codec = QTextCodec::codecForName("iso8859-1");
}
......@@ -629,7 +629,7 @@ CachedXSLStyleSheet::CachedXSLStyleSheet(DocLoader* dl, const DOMString &url, KI
{
// It's XML we want.
// FIXME: This should accept more general xml formats */*+xml, image/svg+xml for example.
setAccept(QString::fromLatin1("text/xml, application/xml, application/xhtml+xml, text/xsl, application/rss+xml, application/atom+xml"));
setAccept("text/xml, application/xml, application/xhtml+xml, text/xsl, application/rss+xml, application/atom+xml");
// load the file
Cache::loader()->load(dl, this, false);
......@@ -695,7 +695,7 @@ CachedXBLDocument::CachedXBLDocument(DocLoader* dl, const DOMString &url, KIO::C
: CachedObject(url, XBL, _cachePolicy, _expireDate), m_document(0)
{
// It's XML we want.
setAccept( QString::fromLatin1("text/xml, application/xml, application/xhtml+xml, text/xsl, application/rss+xml, application/atom+xml") );
setAccept("text/xml, application/xml, application/xhtml+xml, text/xsl, application/rss+xml, application/atom+xml");
// Load the file
Cache::loader()->load(dl, this, false);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment