mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
FIX Auto-escape titles in TreeDropdownField
Related to SS-2013-009. While the default "TreeTitle" was escaped within the SiteTree->TreeTitle() getter, other properties like SiteTree->Title weren't escaped. The new logic uses the underlying casting helpers on the processed objects.
This commit is contained in:
parent
b383a07f90
commit
114fb59107
@ -263,14 +263,28 @@ class TreeDropdownField extends FormField {
|
|||||||
$obj->markToExpose($this->objectForKey($value));
|
$obj->markToExpose($this->objectForKey($value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$eval = '"<li id=\"selector-' . $this->getName() . '-{$child->' . $this->keyField . '}\" data-id=\"$child->'
|
|
||||||
. $this->keyField . '\" class=\"class-$child->class"'
|
$self = $this;
|
||||||
. ' . $child->markingClasses() . "\"><a rel=\"$child->ID\">" . $child->' . $this->labelField . ' . "</a>"';
|
$escapeLabelField = ($obj->escapeTypeForField($this->labelField) != 'xml');
|
||||||
|
$titleFn = function(&$child) use(&$self, $escapeLabelField) {
|
||||||
|
$keyField = $self->keyField;
|
||||||
|
$labelField = $self->labelField;
|
||||||
|
return sprintf(
|
||||||
|
'<li id="selector-%s-%s" data-id="%s" class="class-%s %s"><a rel="%d">%s</a>',
|
||||||
|
Convert::raw2xml($self->getName()),
|
||||||
|
Convert::raw2xml($child->$keyField),
|
||||||
|
Convert::raw2xml($child->$keyField),
|
||||||
|
Convert::raw2xml($child->class),
|
||||||
|
Convert::raw2xml($child->markingClasses()),
|
||||||
|
(int)$child->ID,
|
||||||
|
$escapeLabelField ? Convert::raw2xml($child->$labelField) : $child->$labelField
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
if($isSubTree) {
|
if($isSubTree) {
|
||||||
return substr(trim($obj->getChildrenAsUL('', $eval, null, true, $this->childrenMethod)), 4, -5);
|
return substr(trim($obj->getChildrenAsUL('', $titleFn, null, true, $this->childrenMethod)), 4, -5);
|
||||||
} else {
|
} else {
|
||||||
return $obj->getChildrenAsUL('class="tree"', $eval, null, true, $this->childrenMethod);
|
return $obj->getChildrenAsUL('class="tree"', $titleFn, null, true, $this->childrenMethod);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user