Skip Menu |
Report information
Id: 133791
Status: open
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: warren.music [at] gmail.com
Cc:
AdminCc:

Severity: (no value)
Tag: (no value)
Platform: (no value)
Patch Status: (no value)
VM: (no value)



Subject: perl 6 parser bugging out on a comment thinking it is a real var
To: rakudobug [...] perl.org
From: "Warren W. Music Jr." <warren.music [...] gmail.com>
Date: Wed, 23 Jan 2019 16:26:44 +0700
Download (untitled) / with headers
text/plain 835b
Hello: I ran into this while setting up a post test for json in bailador. While compiling it flags the commented line at the end as bad when the fail should be on the check of request.body[0]. It happened with the latest rakudo built from scratch as of Jan 23rd 2019 as well as rakudo-star 2018.10. Linux Mint system, 64 bit. # --->perl6 t1.pl6 # ===SORRY!=== Error while compiling /home/userx/p6d/tests/latester/t1.pl6 # Variable '%bb' is not declared # at /home/userx/p6d/tests/latester/t1.pl6:97 # ------> #pukes here #say ⏏%bb{"name"}; # code snippet that causes the parser to think # the commented code below is not commented if request.body[0] == "{" { say "JSON"} else {say "NOTJSON"}; # #my %bb = from-json(request.body); # # this one pukes #pukes here #say %bb{"name"};
Usually this happens when you have an unclosed string somewhere earlier in your code.

That is:

say "foo; ← oops! Forgot the closing "

Show quoted text
# $a ← we think that this is a comment, but actually it's part of the string above!
On 2019-01-23 01:27:08, warren.music@gmail.com wrote:
Show quoted text
> Hello:
>
> I ran into this while setting up a post test for json
> in bailador. While compiling it flags the commented
> line at the end as bad when the fail should be on the
> check of request.body[0].
>
> It happened with the latest rakudo built from scratch
> as of Jan 23rd 2019 as well as rakudo-star 2018.10.
>
> Linux Mint system, 64 bit.
>
>
>
>
> # --->perl6 t1.pl6
> # ===SORRY!=== Error while compiling
> /home/userx/p6d/tests/latester/t1.pl6
> # Variable '%bb' is not declared
> # at /home/userx/p6d/tests/latester/t1.pl6:97
> # ------> #pukes here #say ⏏%bb{"name"};
>
> # code snippet that causes the parser to think
> # the commented code below is not commented
> if request.body[0] == "{" { say "JSON"} else {say "NOTJSON"};
>
> # #my %bb = from-json(request.body);
> #
> # this one pukes
> #pukes here #say %bb{"name"};


From: Timo Paulssen <timo [...] wakelift.de>
To: perl6-compiler [...] perl.org
Date: Sat, 26 Jan 2019 14:09:22 +0100
Subject: Re: [perl #133791] perl 6 parser bugging out on a comment thinking it is a real var
Download (untitled) / with headers
text/plain 1.8k
I believe the problem comes from `"{"` which actually starts an interpolated code block containing a string immediately. That's also why it doesn't complain about the "else" being in an odd place; it's also inside the string! So here's an equivalent piece of code that shows what's wrong: if request.body[0] == "" ~ do { qq⟨{ say "JSON"} else {say "NOTJSON"}; # my %bb = 1234 => 99; (and here comes the closing quote for the qq that was missing in the original code: ⟩ Simplifying a tiny bit more: if request.body[0] == "" ~ (say "JSON") ~ " else " ~ (say "NOTJSON") ~ "; # my %bb = 1234 => 99; again no closing double-quotes Does that help? On 25/01/2019 07:20, Aleks-Daniel Jakimenko-Aleksejev via RT wrote: Show quoted text
> Usually this happens when you have an unclosed string somewhere earlier in your > code. > > That is: > > say "foo; ← oops! Forgot the closing " > > # $a ← we think that this is a comment, but actually it's part of the string > above! > On 2019-01-23 01:27:08, warren.music@gmail.com wrote:
>> Hello: >> >> I ran into this while setting up a post test for json >> in bailador. While compiling it flags the commented >> line at the end as bad when the fail should be on the >> check of request.body[0]. >> >> It happened with the latest rakudo built from scratch >> as of Jan 23rd 2019 as well as rakudo-star 2018.10. >> >> Linux Mint system, 64 bit. >> >> >> >> >> # --->perl6 t1.pl6 >> # ===SORRY!=== Error while compiling >> /home/userx/p6d/tests/latester/t1.pl6 >> # Variable '%bb' is not declared >> # at /home/userx/p6d/tests/latester/t1.pl6:97 >> # ------> #pukes here #say ⏏%bb{"name"}; >> >> # code snippet that causes the parser to think >> # the commented code below is not commented >> if request.body[0] == "{" { say "JSON"} else {say "NOTJSON"}; >> >> # #my %bb = from-json(request.body); >> # >> # this one pukes >> #pukes here #say %bb{"name"};
Subject: Re: [perl #133791] perl 6 parser bugging out on a comment thinking it is a real var
Date: Sun, 27 Jan 2019 06:32:52 +0700
To: perl6-bugs-followup [...] perl.org
From: "Warren W. Music Jr." <warren.music [...] gmail.com>
Download (untitled) / with headers
text/plain 2.1k
Oh, for me I just moved on to a proper bit of code. I filed the bug for the perfection of the parser so it's less exploitable. :) "I code therefore I am!" On 1/26/19 8:17 PM, Timo Paulssen via RT wrote: Show quoted text
> I believe the problem comes from `"{"` which actually starts an > interpolated code block containing a string immediately. That's also why > it doesn't complain about the "else" being in an odd place; it's also > inside the string! > > So here's an equivalent piece of code that shows what's wrong: > > if request.body[0] == "" ~ do { qq⟨{ say "JSON"} else {say "NOTJSON"}; > # my %bb = 1234 => 99; > (and here comes the closing quote for the qq that was missing in the original code: ⟩ > > Simplifying a tiny bit more: > > if request.body[0] == "" ~ (say "JSON") ~ " else " ~ (say "NOTJSON") ~ "; > # my %bb = 1234 => 99; > again no closing double-quotes > > Does that help? > > On 25/01/2019 07:20, Aleks-Daniel Jakimenko-Aleksejev via RT wrote:
>> Usually this happens when you have an unclosed string somewhere earlier in your >> code. >> >> That is: >> >> say "foo; ← oops! Forgot the closing " >> >> # $a ← we think that this is a comment, but actually it's part of the string >> above! >> On 2019-01-23 01:27:08, warren.music@gmail.com wrote:
>>> Hello: >>> >>> I ran into this while setting up a post test for json >>> in bailador. While compiling it flags the commented >>> line at the end as bad when the fail should be on the >>> check of request.body[0]. >>> >>> It happened with the latest rakudo built from scratch >>> as of Jan 23rd 2019 as well as rakudo-star 2018.10. >>> >>> Linux Mint system, 64 bit. >>> >>> >>> >>> >>> # --->perl6 t1.pl6 >>> # ===SORRY!=== Error while compiling >>> /home/userx/p6d/tests/latester/t1.pl6 >>> # Variable '%bb' is not declared >>> # at /home/userx/p6d/tests/latester/t1.pl6:97 >>> # ------> #pukes here #say ⏏%bb{"name"}; >>> >>> # code snippet that causes the parser to think >>> # the commented code below is not commented >>> if request.body[0] == "{" { say "JSON"} else {say "NOTJSON"}; >>> >>> # #my %bb = from-json(request.body); >>> # >>> # this one pukes >>> #pukes here #say %bb{"name"};
>
Date: Sat, 26 Jan 2019 05:47:23 +0700
Subject: Re: [perl #133791] perl 6 parser bugging out on a comment thinking it is a real var
From: "Warren W. Music Jr." <warren.music [...] gmail.com>
To: perl6-bugs-followup [...] perl.org
Download (untitled) / with headers
text/plain 1.5k
A missing string never got flagged though. When I comment out the line I call the C line everything worked. I submitted this as a bug since being the worse kind of exploiter I love seeing things like this. I'd go gung ho at using this for malicious activities if I was a hacker. "Concentrationism" On 1/25/19 1:20 PM, Aleks-Daniel Jakimenko-Aleksejev via RT wrote: Show quoted text
> Usually this happens when you have an unclosed string somewhere earlier in your > code. > > That is: > > say "foo; ← oops! Forgot the closing " > > # $a ← we think that this is a comment, but actually it's part of the string > above! > On 2019-01-23 01:27:08, warren.music@gmail.com wrote:
>> Hello: >> >> I ran into this while setting up a post test for json >> in bailador. While compiling it flags the commented >> line at the end as bad when the fail should be on the >> check of request.body[0]. >> >> It happened with the latest rakudo built from scratch >> as of Jan 23rd 2019 as well as rakudo-star 2018.10. >> >> Linux Mint system, 64 bit. >> >> >> >> >> # --->perl6 t1.pl6 >> # ===SORRY!=== Error while compiling >> /home/userx/p6d/tests/latester/t1.pl6 >> # Variable '%bb' is not declared >> # at /home/userx/p6d/tests/latester/t1.pl6:97 >> # ------> #pukes here #say ⏏%bb{"name"}; >> >> # code snippet that causes the parser to think >> # the commented code below is not commented >> if request.body[0] == "{" { say "JSON"} else {say "NOTJSON"}; >> >> # #my %bb = from-json(request.body); >> # >> # this one pukes >> #pukes here #say %bb{"name"};
>


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org