mirror of
https://github.com/xcat2/xcat-core.git
synced 2026-09-04 20:17:55 +00:00
refactor(xcatd): build the parser of both entry points in one place
The module overrides two methods of XML::Simple, one for a recent version and one for an older version, and each built its own parser and set its own handlers. The two bodies were the same apart from spacing, so a change to one refusal had to be repeated in the other, and a reader had to compare them to see that they agreed. Build the parser in one routine that both call. Behaviour does not change.
This commit is contained in:
@@ -50,9 +50,7 @@ sub build_tree_xml_parser {
|
||||
carp "'nsexpand' option requires XML::SAX";
|
||||
}
|
||||
|
||||
my $xp = XML::Parser->new(Style => 'Tree');
|
||||
$xp->setHandlers(ExternEnt => sub { return $_[2] },
|
||||
Doctype => sub { croak 'XML document type declaration is not accepted' });
|
||||
my $xp = _hardened_parser();
|
||||
my($tree);
|
||||
if($filename) {
|
||||
# $tree = $xp->parsefile($filename); # Changed due to prob w/mod_perl
|
||||
@@ -68,8 +66,12 @@ sub build_tree_xml_parser {
|
||||
|
||||
sub new_xml_parser {
|
||||
my($self) = @_;
|
||||
return _hardened_parser();
|
||||
}
|
||||
|
||||
sub _hardened_parser {
|
||||
my $xp = XML::Parser->new(Style => 'Tree');
|
||||
$xp->setHandlers(ExternEnt => sub {return $_[2]},
|
||||
$xp->setHandlers(ExternEnt => sub { return $_[2] },
|
||||
Doctype => sub { croak 'XML document type declaration is not accepted' });
|
||||
return $xp;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user