mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 750096. r=bzbarsky.
This commit is contained in:
parent
d839c86659
commit
79e3d21a31
@ -177,6 +177,11 @@ class NS_STACK_CLASS nsTreeSanitizer {
|
||||
nsIDocument* aDocument,
|
||||
nsIURI* aBaseURI);
|
||||
|
||||
/**
|
||||
* Removes all attributes from an element node.
|
||||
*/
|
||||
void RemoveAllAttributes(nsIContent* aElement);
|
||||
|
||||
/**
|
||||
* The whitelist of HTML elements.
|
||||
*/
|
||||
|
@ -1409,6 +1409,11 @@ nsTreeSanitizer::SanitizeChildren(nsINode* aRoot)
|
||||
PRInt32 ns = nodeInfo->NamespaceID();
|
||||
|
||||
if (MustPrune(ns, localName, elt)) {
|
||||
RemoveAllAttributes(node);
|
||||
nsIContent* descendant = node;
|
||||
while ((descendant = descendant->GetNextNode(node))) {
|
||||
RemoveAllAttributes(descendant);
|
||||
}
|
||||
nsIContent* next = node->GetNextNonChildNode(aRoot);
|
||||
node->GetParent()->RemoveChild(node);
|
||||
node = next;
|
||||
@ -1452,6 +1457,7 @@ nsTreeSanitizer::SanitizeChildren(nsINode* aRoot)
|
||||
continue;
|
||||
}
|
||||
if (MustFlatten(ns, localName)) {
|
||||
RemoveAllAttributes(node);
|
||||
nsIContent* next = node->GetNextNode(aRoot);
|
||||
nsIContent* parent = node->GetParent();
|
||||
nsCOMPtr<nsIContent> child; // Must keep the child alive during move
|
||||
@ -1504,6 +1510,17 @@ nsTreeSanitizer::SanitizeChildren(nsINode* aRoot)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsTreeSanitizer::RemoveAllAttributes(nsIContent* aElement)
|
||||
{
|
||||
const nsAttrName* attrName;
|
||||
while ((attrName = aElement->GetAttrNameAt(0))) {
|
||||
PRInt32 attrNs = attrName->NamespaceID();
|
||||
nsCOMPtr<nsIAtom> attrLocal = attrName->LocalName();
|
||||
aElement->UnsetAttr(attrNs, attrLocal, false);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsTreeSanitizer::InitializeStatics()
|
||||
{
|
||||
|
@ -2297,6 +2297,8 @@ nsresult nsHTMLEditor::ParseFragment(const nsAString & aFragStr,
|
||||
nsCOMPtr<nsIDOMNode> *outNode,
|
||||
bool aTrustedInput)
|
||||
{
|
||||
nsAutoScriptBlockerSuppressNodeRemoved autoBlocker;
|
||||
|
||||
nsCOMPtr<nsIDOMDocumentFragment> frag;
|
||||
NS_NewDocumentFragment(getter_AddRefs(frag),
|
||||
aTargetDocument->NodeInfoManager());
|
||||
|
@ -149,6 +149,8 @@ nsParserUtils::ParseFragment(const nsAString& aFragment,
|
||||
document = do_QueryInterface(domDocument);
|
||||
NS_ENSURE_TRUE(document, NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
nsAutoScriptBlockerSuppressNodeRemoved autoBlocker;
|
||||
|
||||
// stop scripts
|
||||
nsRefPtr<nsScriptLoader> loader;
|
||||
bool scripts_enabled = false;
|
||||
|
Loading…
Reference in New Issue
Block a user