bug 384507. nsContentSink.h contains static non-member functions and globals. r+sr=jst

This commit is contained in:
sayrer@gmail.com 2007-06-18 15:44:11 -07:00
Родитель 9d0c915718
Коммит 5939f50f17
4 изменённых файлов: 189 добавлений и 184 удалений

Просмотреть файл

@ -1540,3 +1540,178 @@ nsContentSink::ContinueInterruptedParsingAsync()
NS_DispatchToCurrentThread(ev);
}
// URIs: action, href, src, longdesc, usemap, cite
PRBool
IsAttrURI(nsIAtom *aName)
{
return (aName == nsGkAtoms::action ||
aName == nsGkAtoms::href ||
aName == nsGkAtoms::src ||
aName == nsGkAtoms::longdesc ||
aName == nsGkAtoms::usemap ||
aName == nsGkAtoms::cite ||
aName == nsGkAtoms::background);
}
//
// these two lists are used by the sanitizing fragment serializers
// Thanks to Mark Pilgrim and Sam Ruby for the initial whitelist
//
nsIAtom** const kDefaultAllowedTags [] = {
&nsGkAtoms::a,
&nsGkAtoms::abbr,
&nsGkAtoms::acronym,
&nsGkAtoms::address,
&nsGkAtoms::area,
&nsGkAtoms::b,
&nsGkAtoms::bdo,
&nsGkAtoms::big,
&nsGkAtoms::blockquote,
&nsGkAtoms::br,
&nsGkAtoms::button,
&nsGkAtoms::caption,
&nsGkAtoms::center,
&nsGkAtoms::cite,
&nsGkAtoms::code,
&nsGkAtoms::col,
&nsGkAtoms::colgroup,
&nsGkAtoms::dd,
&nsGkAtoms::del,
&nsGkAtoms::dfn,
&nsGkAtoms::dir,
&nsGkAtoms::div,
&nsGkAtoms::dl,
&nsGkAtoms::dt,
&nsGkAtoms::em,
&nsGkAtoms::fieldset,
&nsGkAtoms::font,
&nsGkAtoms::form,
&nsGkAtoms::h1,
&nsGkAtoms::h2,
&nsGkAtoms::h3,
&nsGkAtoms::h4,
&nsGkAtoms::h5,
&nsGkAtoms::h6,
&nsGkAtoms::hr,
&nsGkAtoms::i,
&nsGkAtoms::img,
&nsGkAtoms::input,
&nsGkAtoms::ins,
&nsGkAtoms::kbd,
&nsGkAtoms::label,
&nsGkAtoms::legend,
&nsGkAtoms::li,
&nsGkAtoms::listing,
&nsGkAtoms::map,
&nsGkAtoms::menu,
&nsGkAtoms::nobr,
&nsGkAtoms::ol,
&nsGkAtoms::optgroup,
&nsGkAtoms::option,
&nsGkAtoms::p,
&nsGkAtoms::pre,
&nsGkAtoms::q,
&nsGkAtoms::s,
&nsGkAtoms::samp,
&nsGkAtoms::select,
&nsGkAtoms::small,
&nsGkAtoms::span,
&nsGkAtoms::strike,
&nsGkAtoms::strong,
&nsGkAtoms::sub,
&nsGkAtoms::sup,
&nsGkAtoms::table,
&nsGkAtoms::tbody,
&nsGkAtoms::td,
&nsGkAtoms::textarea,
&nsGkAtoms::tfoot,
&nsGkAtoms::th,
&nsGkAtoms::thead,
&nsGkAtoms::tr,
&nsGkAtoms::tt,
&nsGkAtoms::u,
&nsGkAtoms::ul,
&nsGkAtoms::var,
nsnull
};
nsIAtom** const kDefaultAllowedAttributes [] = {
&nsGkAtoms::abbr,
&nsGkAtoms::accept,
&nsGkAtoms::acceptcharset,
&nsGkAtoms::accesskey,
&nsGkAtoms::action,
&nsGkAtoms::align,
&nsGkAtoms::alt,
&nsGkAtoms::autocomplete,
&nsGkAtoms::axis,
&nsGkAtoms::background,
&nsGkAtoms::bgcolor,
&nsGkAtoms::border,
&nsGkAtoms::cellpadding,
&nsGkAtoms::cellspacing,
&nsGkAtoms::_char,
&nsGkAtoms::charoff,
&nsGkAtoms::charset,
&nsGkAtoms::checked,
&nsGkAtoms::cite,
&nsGkAtoms::_class,
&nsGkAtoms::clear,
&nsGkAtoms::cols,
&nsGkAtoms::colspan,
&nsGkAtoms::color,
&nsGkAtoms::compact,
&nsGkAtoms::coords,
&nsGkAtoms::datetime,
&nsGkAtoms::dir,
&nsGkAtoms::disabled,
&nsGkAtoms::enctype,
&nsGkAtoms::_for,
&nsGkAtoms::frame,
&nsGkAtoms::headers,
&nsGkAtoms::height,
&nsGkAtoms::href,
&nsGkAtoms::hreflang,
&nsGkAtoms::hspace,
&nsGkAtoms::id,
&nsGkAtoms::ismap,
&nsGkAtoms::label,
&nsGkAtoms::lang,
&nsGkAtoms::longdesc,
&nsGkAtoms::maxlength,
&nsGkAtoms::media,
&nsGkAtoms::method,
&nsGkAtoms::multiple,
&nsGkAtoms::name,
&nsGkAtoms::nohref,
&nsGkAtoms::noshade,
&nsGkAtoms::nowrap,
&nsGkAtoms::pointSize,
&nsGkAtoms::prompt,
&nsGkAtoms::readonly,
&nsGkAtoms::rel,
&nsGkAtoms::rev,
&nsGkAtoms::role,
&nsGkAtoms::rows,
&nsGkAtoms::rowspan,
&nsGkAtoms::rules,
&nsGkAtoms::scope,
&nsGkAtoms::selected,
&nsGkAtoms::shape,
&nsGkAtoms::size,
&nsGkAtoms::span,
&nsGkAtoms::src,
&nsGkAtoms::start,
&nsGkAtoms::summary,
&nsGkAtoms::tabindex,
&nsGkAtoms::target,
&nsGkAtoms::title,
&nsGkAtoms::type,
&nsGkAtoms::usemap,
&nsGkAtoms::valign,
&nsGkAtoms::value,
&nsGkAtoms::vspace,
&nsGkAtoms::width,
nsnull
};

Просмотреть файл

@ -302,177 +302,9 @@ protected:
MOZ_TIMER_DECLARE(mWatch)
};
// sanitizing content sink whitelists
extern PRBool IsAttrURI(nsIAtom *aName);
extern nsIAtom** const kDefaultAllowedTags [];
extern nsIAtom** const kDefaultAllowedAttributes [];
//
// these two lists are used by the sanitizing fragment serializers
// Thanks to Mark Pilgrim and Sam Ruby for the initial whitelist
//
static nsIAtom** const kDefaultAllowedTags [] = {
&nsGkAtoms::a,
&nsGkAtoms::abbr,
&nsGkAtoms::acronym,
&nsGkAtoms::address,
&nsGkAtoms::area,
&nsGkAtoms::b,
&nsGkAtoms::bdo,
&nsGkAtoms::big,
&nsGkAtoms::blockquote,
&nsGkAtoms::br,
&nsGkAtoms::button,
&nsGkAtoms::caption,
&nsGkAtoms::center,
&nsGkAtoms::cite,
&nsGkAtoms::code,
&nsGkAtoms::col,
&nsGkAtoms::colgroup,
&nsGkAtoms::dd,
&nsGkAtoms::del,
&nsGkAtoms::dfn,
&nsGkAtoms::dir,
&nsGkAtoms::div,
&nsGkAtoms::dl,
&nsGkAtoms::dt,
&nsGkAtoms::em,
&nsGkAtoms::fieldset,
&nsGkAtoms::font,
&nsGkAtoms::form,
&nsGkAtoms::h1,
&nsGkAtoms::h2,
&nsGkAtoms::h3,
&nsGkAtoms::h4,
&nsGkAtoms::h5,
&nsGkAtoms::h6,
&nsGkAtoms::hr,
&nsGkAtoms::i,
&nsGkAtoms::img,
&nsGkAtoms::input,
&nsGkAtoms::ins,
&nsGkAtoms::kbd,
&nsGkAtoms::label,
&nsGkAtoms::legend,
&nsGkAtoms::li,
&nsGkAtoms::listing,
&nsGkAtoms::map,
&nsGkAtoms::menu,
&nsGkAtoms::nobr,
&nsGkAtoms::ol,
&nsGkAtoms::optgroup,
&nsGkAtoms::option,
&nsGkAtoms::p,
&nsGkAtoms::pre,
&nsGkAtoms::q,
&nsGkAtoms::s,
&nsGkAtoms::samp,
&nsGkAtoms::select,
&nsGkAtoms::small,
&nsGkAtoms::span,
&nsGkAtoms::strike,
&nsGkAtoms::strong,
&nsGkAtoms::sub,
&nsGkAtoms::sup,
&nsGkAtoms::table,
&nsGkAtoms::tbody,
&nsGkAtoms::td,
&nsGkAtoms::textarea,
&nsGkAtoms::tfoot,
&nsGkAtoms::th,
&nsGkAtoms::thead,
&nsGkAtoms::tr,
&nsGkAtoms::tt,
&nsGkAtoms::u,
&nsGkAtoms::ul,
&nsGkAtoms::var
};
static nsIAtom** const kDefaultAllowedAttributes [] = {
&nsGkAtoms::abbr,
&nsGkAtoms::accept,
&nsGkAtoms::acceptcharset,
&nsGkAtoms::accesskey,
&nsGkAtoms::action,
&nsGkAtoms::align,
&nsGkAtoms::alt,
&nsGkAtoms::autocomplete,
&nsGkAtoms::axis,
&nsGkAtoms::background,
&nsGkAtoms::bgcolor,
&nsGkAtoms::border,
&nsGkAtoms::cellpadding,
&nsGkAtoms::cellspacing,
&nsGkAtoms::_char,
&nsGkAtoms::charoff,
&nsGkAtoms::charset,
&nsGkAtoms::checked,
&nsGkAtoms::cite,
&nsGkAtoms::_class,
&nsGkAtoms::clear,
&nsGkAtoms::cols,
&nsGkAtoms::colspan,
&nsGkAtoms::color,
&nsGkAtoms::compact,
&nsGkAtoms::coords,
&nsGkAtoms::datetime,
&nsGkAtoms::dir,
&nsGkAtoms::disabled,
&nsGkAtoms::enctype,
&nsGkAtoms::_for,
&nsGkAtoms::frame,
&nsGkAtoms::headers,
&nsGkAtoms::height,
&nsGkAtoms::href,
&nsGkAtoms::hreflang,
&nsGkAtoms::hspace,
&nsGkAtoms::id,
&nsGkAtoms::ismap,
&nsGkAtoms::label,
&nsGkAtoms::lang,
&nsGkAtoms::longdesc,
&nsGkAtoms::maxlength,
&nsGkAtoms::media,
&nsGkAtoms::method,
&nsGkAtoms::multiple,
&nsGkAtoms::name,
&nsGkAtoms::nohref,
&nsGkAtoms::noshade,
&nsGkAtoms::nowrap,
&nsGkAtoms::pointSize,
&nsGkAtoms::prompt,
&nsGkAtoms::readonly,
&nsGkAtoms::rel,
&nsGkAtoms::rev,
&nsGkAtoms::role,
&nsGkAtoms::rows,
&nsGkAtoms::rowspan,
&nsGkAtoms::rules,
&nsGkAtoms::scope,
&nsGkAtoms::selected,
&nsGkAtoms::shape,
&nsGkAtoms::size,
&nsGkAtoms::span,
&nsGkAtoms::src,
&nsGkAtoms::start,
&nsGkAtoms::summary,
&nsGkAtoms::tabindex,
&nsGkAtoms::target,
&nsGkAtoms::title,
&nsGkAtoms::type,
&nsGkAtoms::usemap,
&nsGkAtoms::valign,
&nsGkAtoms::value,
&nsGkAtoms::vspace,
&nsGkAtoms::width
};
// URIs action, href, src, longdesc, usemap, cite
static
PRBool IsAttrURI(nsIAtom *aName)
{
return (aName == nsGkAtoms::action ||
aName == nsGkAtoms::href ||
aName == nsGkAtoms::src ||
aName == nsGkAtoms::longdesc ||
aName == nsGkAtoms::usemap ||
aName == nsGkAtoms::cite ||
aName == nsGkAtoms::background);
}
#endif // _nsContentSink_h_

Просмотреть файл

@ -893,22 +893,21 @@ nsHTMLParanoidFragmentSink::Init()
return NS_OK;
}
PRUint32 size = NS_ARRAY_LENGTH(kDefaultAllowedTags);
sAllowedTags = new nsTHashtable<nsISupportsHashKey>();
if (sAllowedTags) {
rv = sAllowedTags->Init(size);
for (PRUint32 i = 0; i < size && NS_SUCCEEDED(rv); i++) {
rv = sAllowedTags->Init(80);
for (PRUint32 i = 0; kDefaultAllowedTags[i] && NS_SUCCEEDED(rv); i++) {
if (!sAllowedTags->PutEntry(*kDefaultAllowedTags[i])) {
rv = NS_ERROR_OUT_OF_MEMORY;
}
}
}
size = NS_ARRAY_LENGTH(kDefaultAllowedAttributes);
sAllowedAttributes = new nsTHashtable<nsISupportsHashKey>();
if (sAllowedAttributes && NS_SUCCEEDED(rv)) {
rv = sAllowedAttributes->Init(size);
for (PRUint32 i = 0; i < size && NS_SUCCEEDED(rv); i++) {
rv = sAllowedAttributes->Init(80);
for (PRUint32 i = 0;
kDefaultAllowedAttributes[i] && NS_SUCCEEDED(rv); i++) {
if (!sAllowedAttributes->PutEntry(*kDefaultAllowedAttributes[i])) {
rv = NS_ERROR_OUT_OF_MEMORY;
}

Просмотреть файл

@ -513,22 +513,21 @@ nsXHTMLParanoidFragmentSink::Init()
return NS_OK;
}
PRUint32 size = NS_ARRAY_LENGTH(kDefaultAllowedTags);
sAllowedTags = new nsTHashtable<nsISupportsHashKey>();
if (sAllowedTags) {
rv = sAllowedTags->Init(size);
for (PRUint32 i = 0; i < size && NS_SUCCEEDED(rv); i++) {
rv = sAllowedTags->Init(80);
for (PRUint32 i = 0; kDefaultAllowedTags[i] && NS_SUCCEEDED(rv); i++) {
if (!sAllowedTags->PutEntry(*kDefaultAllowedTags[i])) {
rv = NS_ERROR_OUT_OF_MEMORY;
}
}
}
size = NS_ARRAY_LENGTH(kDefaultAllowedAttributes);
sAllowedAttributes = new nsTHashtable<nsISupportsHashKey>();
if (sAllowedAttributes && NS_SUCCEEDED(rv)) {
rv = sAllowedAttributes->Init(size);
for (PRUint32 i = 0; i < size && NS_SUCCEEDED(rv); i++) {
rv = sAllowedAttributes->Init(80);
for (PRUint32 i = 0;
kDefaultAllowedAttributes[i] && NS_SUCCEEDED(rv); i++) {
if (!sAllowedAttributes->PutEntry(*kDefaultAllowedAttributes[i])) {
rv = NS_ERROR_OUT_OF_MEMORY;
}