Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Grammar matches against non-URI strings #4

Open
bbkr opened this Issue · 3 comments

2 participants

@bbkr

IRC log

14:03 bbkr: star: use IETF::RFC_Grammar::URI; say so " " ~~  m/<IETF::RFC_Grammar::URI::TOP>/
14:03 p6eval: star 2012.05: OUTPUT«True␤»
14:04 jnthn: ...that doens't look like a URI to me :)
14:04 bbkr: indeed, creating GH issue now...
14:09 moritz: ah, and the space is never parsed, because the regex is not anchored
@ronaldxs
Collaborator

RFC 3986, Uniform Resource Identifier (URI): Generic Syntax, has a section (4.2) on the "Relative Reference" which makes the empty string a valid relative reference, or URI of sorts, relative to a base URI. So relative to http://github.com both the empty string and '/foo.html' are valid relative references. I have chosen to make a relative reference a valid thing to parse as an URI. In response to this situation w3 (see http://www.w3.org/TR/2011/WD-html5-20110113/author/urls.html) has identified the concept of "a valid non-empty URL".

As discussed on IRC yesterday, http://irclog.perlgeek.de/perl6/2012-05-31#i_5662923, the URI module has a validating URI rule which somewhat addresses the initial complaint of treating " " as an URI. If you don't need relative references there is also a URI rule which should match http://gitub.com and ftp://rakudo.org.

You raised an objection that sometimes you are searching for URIs and matching the empty string doesn't really make sense. In response I propose to add a "valid non-empty URL(/URI)" rule which can be used for such searches.

Thoughts??

@ronaldxs
Collaborator

Since there was no other comment on this matter I added a grammar rule TOP_non_empty to partially remedy bbkr's complaint. It seems to me that it is reasonable to add a search method to the URI module, which would also make it easy to add some tests. Note that this functionality goes beyond Perl 5 URI AFAIK. The additional step is a bit involved since I think it would also make sense for the search method to be lazy and fixing that may wait for another day. So some progress on this issue but leaving it open for now.

@ronaldxs
Collaborator

Resolution of this now depends on an open rakudo ticket https://rt.perl.org/rt3/Ticket/Display.html?id=112716

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.