Subject: | Bug report (minor): URI::Template fails on empty or zero template |
Date: | Tue, 23 Dec 2014 22:29:15 -0500 |
To: | bug-URI-Template [...] rt.cpan.org |
From: | David Booth <david [...] dbooth.org> |
Thanks for a very useful module! I noticed one minor bug though.
RFC6570 defines the URI Template syntax, and permits a URI Template to
be the empty string, as shown in this EBNF:
https://tools.ietf.org/html/rfc6570#page-13
[[
URI-Template = *( literals / expression )
]]
However, when URI::Template->new("") is called (i.e., passing an empty
string as the template), it dies with the following error message:
[[
No template provided at /usr/local/share/perl/5.14.2/URI/Template.pm
line 27.
]]
It similarly dies if 0 or "0" is passed as the template.
The error is generated from URI/Template.pm line 27, which says:
[[
my $templ = shift || die 'No template provided';
]]
This might be fixable simply by changing line 27 to:
[[
my $templ = shift;
defined($templ) || die 'No template provided';
]]
however I have not tested this potential fix, and I don't know whether
other parts of the logic depend on the template being non empty.
Thanks!
David Booth