From bbcb30140c7638c8db09ed1494d84c223ed000c8 Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Wed, 21 Aug 2019 15:29:09 +0300 Subject: [PATCH] Add regex_escape() TT function --- Bugzilla/Template.pm | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Bugzilla/Template.pm b/Bugzilla/Template.pm index 2555e2144..adea2e86a 100644 --- a/Bugzilla/Template.pm +++ b/Bugzilla/Template.pm @@ -956,6 +956,21 @@ sub create # html_quote in the form of a function html => \&html_quote, + # escape regular expression characters + regex_escape => sub + { + my ($s) = @_; + return "\Q$s\E"; + }, + + # escape regular expression replacement characters + replacement_escape => sub + { + my ($s) = @_; + $s =~ s/([\\\$])/\\$1/gso; + return $s; + }, + # HTML