Prevent a label's for content from being another label (or itself), which can lead to crashes. b=237357 Patch from Rene Pronk <r.pronk@its.tudelft.nl>. sr=dbaron r=jst a=chofmann
git-svn-id: svn://10.0.0.236/trunk@153992 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -359,6 +359,12 @@ nsHTMLLabelElement::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
|
||||
return nsGenericHTMLElement::UnsetAttr(aNameSpaceID, aAttribute, aNotify);
|
||||
}
|
||||
|
||||
inline PRBool IsNonLabelFormControl(nsIContent *aContent)
|
||||
{
|
||||
return aContent->IsContentOfType(nsIContent::eHTML_FORM_CONTROL) &&
|
||||
aContent->Tag() != nsHTMLAtoms::label;
|
||||
}
|
||||
|
||||
already_AddRefed<nsIContent>
|
||||
nsHTMLLabelElement::GetForContent()
|
||||
{
|
||||
@@ -377,7 +383,7 @@ nsHTMLLabelElement::GetForContent()
|
||||
nsIContent *result = nsnull;
|
||||
if (domElement) {
|
||||
CallQueryInterface(domElement, &result);
|
||||
if (result && !result->IsContentOfType(nsIContent::eHTML_FORM_CONTROL)) {
|
||||
if (result && !IsNonLabelFormControl(result)) {
|
||||
NS_RELEASE(result); // assigns null
|
||||
}
|
||||
}
|
||||
@@ -399,7 +405,7 @@ nsHTMLLabelElement::GetFirstFormControl(nsIContent *current)
|
||||
for (PRUint32 i = 0; i < numNodes; i++) {
|
||||
nsIContent *child = current->GetChildAt(i);
|
||||
if (child) {
|
||||
if (child->IsContentOfType(nsIContent::eHTML_FORM_CONTROL)) {
|
||||
if (IsNonLabelFormControl(child)) {
|
||||
NS_ADDREF(child);
|
||||
return child;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user