Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grammar matches against non-URI strings #4

Open
bbkr opened this issue May 31, 2012 · 3 comments
Open

Grammar matches against non-URI strings #4

bbkr opened this issue May 31, 2012 · 3 comments

Comments

@bbkr
Copy link

bbkr commented May 31, 2012

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
Copy link
Collaborator

ronaldxs commented Jun 1, 2012

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
Copy link
Collaborator

ronaldxs commented Jun 7, 2012

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
Copy link
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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants