Skip Menu |

This queue is for tickets about the URI-Template CPAN distribution.

Report information
The Basics
Id: 101109
Status: resolved
Priority: 0/
Queue: URI-Template

People
Owner: Nobody in particular
Requestors: david [...] dbooth.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



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
Fixed in version 0.19. Thanks.
From: david [...] dbooth.org
On Mon Jan 05 18:52:15 2015, BRICAS wrote: Show quoted text
> Fixed in version 0.19. > > Thanks.
Unfortunately that fix introduced a more important bug: it will silently change a template of "0" to "". A URI template can be for a relative URI, and "0" is a legal relative URI, but it is treated as a false boolean value in perl. Line 27: [[ my $templ = shift || ''; ]] needs to be changed to something like: [[ my $templ = shift; defined($templ) || die 'No template provided'; ]] Thanks!
Try 0.20. :) -Brian
From: david [...] dbooth.org
On Mon Jan 05 21:09:47 2015, BRICAS wrote: Show quoted text
> Try 0.20. :) > > -Brian
Thanks! :)