nginx-java-parser icon indicating copy to clipboard operation
nginx-java-parser copied to clipboard

Parsing of perl sub with backslash fails

Open CodingFabian opened this issue 8 years ago • 0 comments

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 :))

CodingFabian avatar Oct 13 '16 20:10 CodingFabian