Subject: | [PATCH] Escape sent string when used in regex |
Otherwise metacharacters in the sent string interfere with the match and
may lead to an invalid regex pattern.
--- a/Test/Expect.pm 2012-12-14 13:57:05.000000000 -0800
+++ b/Test/Expect.pm 2012-12-14 13:57:25.000000000 -0800
@@ -56,7 +56,7 @@
sub before {
my $before = $expect->before;
$before =~ s/\r//g;
- $before =~ s/^$sent// if $sent;
+ $before =~ s/^\Q$sent\E// if $sent;
$before =~ s/^\n+//;
$before =~ s/\n+$//;
return $before;