odiszapc / nginx-java-parser

Nginx configuration parser based on ANTLR4 grammar
260 stars 87 forks source link

Parsing of perl sub with backslash fails #12

Open CodingFabian opened 8 years ago

CodingFabian commented 8 years ago

Take this perl function which should strip a password out of the url:

                perl_set $strippw '
                        sub {
                                my $r = shift;
                                my $uri = $r->uri;
                                return $uri if !$r->args;
                                $uri = $uri."?".$r->args;
                                $uri =~ s/password=\w+&?//g;
                                return $uri;
                                }
                        ';

The parsing will fail:

line 37:18 token recognition error at: ''\nsub {\nmy $r = shift;\nmy $uri = $r->uri;\nreturn $uri if !$r->args;\n$uri = $uri."?".$r->args;\n$uri =~ s/password=\'

without the backslash w, this would parse fine (but that would be a broken regex then :))