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

Identities that contain < or > fail to parse #327

Closed
ugexe opened this issue Dec 1, 2019 · 0 comments · Fixed by #329
Closed

Identities that contain < or > fail to parse #327

ugexe opened this issue Dec 1, 2019 · 0 comments · Fixed by #329
Labels

Comments

@ugexe
Copy link
Owner

ugexe commented Dec 1, 2019

# Grammar and Actions from Zef::Identity
my grammar REQUIRE {
    regex TOP { ^^ <name> [':' <key> <value>]* $$ }

    regex name  { <-restricted +name-sep>+ }
    token key   { <-restricted>+ }
    token value { '<' ~ '>'  [<( [[ <!before \>|\\> . ]+]* % ['\\' . ] )>] }

    token restricted { [':' | '<' | '>' | '(' | ')'] }
    token name-sep   { < :: > }
}
my class REQUIRE::Actions {
    method TOP($/) { make %('name'=> $/<name>.made, %($/<key> Z=> $/<value>>>.ast)) if $/ }

    method name($/)  { make $/.Str }
    method key($/)   { my $str = make $/.Str; ($str eq 'ver') ?? 'version' !! $str }
    method value($/) { make $/.Str }
}

my $g = REQUIRE.new(:actions(REQUIRE::Actions));

say $g.parse("Sake::TaskStore:ver<0.0.3>:auth<>:api<>");
#「Sake::TaskStore:ver<0.0.3>:auth<>:api<>」
# name => 「Sake::TaskStore」
# key => 「ver」
# value => 「0.0.3」
# key => 「auth」
# value => 「」
# key => 「api」
# value => 「」

say $g.parse("Sake::TaskStore:ver<0.0.3>:auth<Jonathan Scott Duff <duff\@pobox.com>>:api<>");
# Nil
@ugexe ugexe added the bug label Dec 1, 2019
AlexDaniel added a commit to Raku/whateverable that referenced this issue Dec 10, 2019
ugexe added a commit that referenced this issue Dec 13, 2019
Previously searching for a name of a module (not a distribution
name) any auth that would contain a < or > would cause any
matching to fail. This fixes the grammar to properly parse
such characters in an identity string, as well as changing
how identities are constructed for provides to avoid parsing
from a string (instead setting the attributes directly).

Resolves #327
ugexe added a commit that referenced this issue Dec 15, 2019
Previously searching for a name of a module (not a distribution
name) any auth that would contain a < or > would cause any
matching to fail. This fixes the grammar to properly parse
such characters in an identity string, as well as changing
how identities are constructed for provides to avoid parsing
from a string (instead setting the attributes directly).

Resolves #327
ugexe added a commit that referenced this issue Feb 11, 2020
Previously searching for a name of a module (not a distribution
name) any auth that would contain a < or > would cause any
matching to fail. This fixes the grammar to properly parse
such characters in an identity string, as well as changing
how identities are constructed for provides to avoid parsing
from a string (instead setting the attributes directly).

Resolves #327
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant