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> 2006-01-03 Justin Garcia <justin.garcia@apple.com>
<http://bugzilla.opendarwin.org/show_bug.cgi?id=4904> <http://bugzilla.opendarwin.org/show_bug.cgi?id=4904>
......
...@@ -307,21 +307,19 @@ bool HTMLFormElementImpl::formData(FormData &form_data) const ...@@ -307,21 +307,19 @@ bool HTMLFormElementImpl::formData(FormData &form_data) const
QStringList charsets = QStringList::split(' ', str); QStringList charsets = QStringList::split(' ', str);
QTextCodec* codec = 0; QTextCodec* codec = 0;
KHTMLPart *part = getDocument()->part(); 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); QString enc = (*it);
if(enc.contains("UNKNOWN")) if (enc.contains("UNKNOWN")) {
{
// use standard document encoding // use standard document encoding
enc = "ISO-8859-1"; enc = "ISO-8859-1";
if (part) if (part)
enc = part->encoding(); enc = part->encoding();
} }
if((codec = QTextCodec::codecForName(enc.latin1()))) if ((codec = QTextCodec::codecForName(enc.latin1())))
break; break;
} }
if(!codec) if (!codec)
codec = QTextCodec::codecForLocale(); codec = QTextCodec::codecForLocale();
......
...@@ -160,16 +160,16 @@ void CachedObject::setSize(int size) ...@@ -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) 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. // It's css we want.
setAccept( QString::fromLatin1("text/css") ); setAccept("text/css");
// load the file // load the file
Cache::loader()->load(dl, this, false); Cache::loader()->load(dl, this, false);
m_loading = true; m_loading = true;
if(!charset.isEmpty()) if (!charset.isEmpty())
m_codec = QTextCodec::codecForName(charset.latin1()); m_codec = QTextCodec::codecForName(charset.latin1());
else if (!m_codec)
m_codec = QTextCodec::codecForName("iso8859-1"); m_codec = QTextCodec::codecForName("iso8859-1");
} }
...@@ -247,19 +247,19 @@ void CachedCSSStyleSheet::error( int /*err*/, const char */*text*/ ) ...@@ -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) 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. // It's javascript we want.
// But some websites think their scripts are <some wrong mimetype here> // But some websites think their scripts are <some wrong mimetype here>
// and refuse to serve them if we only accept application/x-javascript. // and refuse to serve them if we only accept application/x-javascript.
setAccept( QString::fromLatin1("*/*") ); setAccept("*/*");
m_errorOccurred = false; m_errorOccurred = false;
// load the file // load the file
Cache::loader()->load(dl, this, false); Cache::loader()->load(dl, this, false);
m_loading = true; m_loading = true;
if(!charset.isEmpty()) if (!charset.isEmpty())
m_codec = QTextCodec::codecForName(charset.latin1()); m_codec = QTextCodec::codecForName(charset.latin1());
else if (!m_codec)
m_codec = QTextCodec::codecForName("iso8859-1"); m_codec = QTextCodec::codecForName("iso8859-1");
} }
...@@ -629,7 +629,7 @@ CachedXSLStyleSheet::CachedXSLStyleSheet(DocLoader* dl, const DOMString &url, KI ...@@ -629,7 +629,7 @@ CachedXSLStyleSheet::CachedXSLStyleSheet(DocLoader* dl, const DOMString &url, KI
{ {
// It's XML we want. // It's XML we want.
// FIXME: This should accept more general xml formats */*+xml, image/svg+xml for example. // 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 // load the file
Cache::loader()->load(dl, this, false); Cache::loader()->load(dl, this, false);
...@@ -695,7 +695,7 @@ CachedXBLDocument::CachedXBLDocument(DocLoader* dl, const DOMString &url, KIO::C ...@@ -695,7 +695,7 @@ CachedXBLDocument::CachedXBLDocument(DocLoader* dl, const DOMString &url, KIO::C
: CachedObject(url, XBL, _cachePolicy, _expireDate), m_document(0) : CachedObject(url, XBL, _cachePolicy, _expireDate), m_document(0)
{ {
// It's XML we want. // 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 // Load the file
Cache::loader()->load(dl, this, false); 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