Skip to content

Be more careful with format name #76

Closed

Description

@davorg

XML::Feed::new and XML::Feed::parse build a class name by interpolating their format argument and loading it with a string eval: my $format_class = 'XML::Feed::Format::' . $format; eval "use $format_class". Nothing constrains the name, so a format containing a semicolon has the remainder run as Perl; we confirmed this through both entry points. Both methods document format as an ordinary argument, and choosing a feed format from a query parameter (format=RSS) is a common content-negotiation pattern, so an application can reasonably pass a value it does not fully control.

I suggest the following:

  • In the BEGIN block in lib/XML/Feed.pm also create a package variable %formatters which maps format names to a true value
  • Whenever we're passed a string to use as a format name, check %formatters for valid values
  • die on an invalid value

Also, add tests for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions