#!/usr/bin/perl use strict; use warnings; use CGI::Carp qw(fatalsToBrowser); use Path::Tiny; use lib path (__FILE__)->parent->parent->child ('lib')->stringify; use Web::Encoding; sub htescape ($) { my $s = shift; $s =~ s/&/&/g; $s =~ s/</g; $s =~ s/"/"/g; return $s; } # htescape my %qp = map { s/%([0-9A-Fa-f]{2})/pack 'C', hex $1/ge; $_ } map { split /=/, $_, 2 } split /&/, $ENV{QUERY_STRING} // ''; my $regexp = decode_web_utf8 $qp{s} // ''; $regexp = '(?:)' unless length $regexp; my $eregexp = htescape $regexp; my $lang = $qp{l} // 'perl58'; my $class = $lang eq 'js' ? 'Regexp::Parser::JavaScript' : 'Regexp::Parser::Perl58'; eval qq{ require $class } or die $@; my $parser = $class->new; my $footer = q[ ]; my @error; $parser->onerror (sub { my %args = @_; my $r = '
';
$r .= htescape substr ${$args{valueref}}, 0, $args{pos_start};
$r .= '';
$r .= htescape substr ${$args{valueref}},
$args{pos_start}, $args{pos_end} - $args{pos_start};
$r .= '';
$r .= htescape substr ${$args{valueref}}, $args{pos_end};
$r .= '
Input: ], $eregexp, q[
Error:
Input: ], $eregexp, q[