From 55bee6cdccae3a83200c799a23a4fda4d135717f Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Thu, 1 Sep 2016 20:57:51 +0300 Subject: [PATCH] Only unescape correct UTF8 sequences in MediaWiki page sections --- Bugzilla/Template.pm | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Bugzilla/Template.pm b/Bugzilla/Template.pm index 5911785d3..7a095e2e2 100644 --- a/Bugzilla/Template.pm +++ b/Bugzilla/Template.pm @@ -422,9 +422,15 @@ sub unquote_wiki_url my $anchor = ''; if ($article =~ s/#(.*)$//so) { + my $a; $anchor = $1; - # decode MediaWiki page section name - $anchor =~ tr/./%/; + # decode MediaWiki page section name (only correct UTF8 sequences) + $anchor =~ s/( + \.[0-7][A-F0-9]| + \.[CD][A-F0-9]\.[89AB][A-F0-9]| + \.E[A-F0-9](?:\.[89AB][A-F0-9]){2}| + \.F[0-7](?:\.[89AB][A-F0-9]){3} + )/($a = $1), ($a =~ tr!.!\%!), ($a)/gesx; $anchor = url_decode($anchor); $anchor =~ tr/_/ /; }