Open
Bug 726607
Opened 14 years ago
Updated 10 years ago
Substitutions in URLs done by the bug_format_comment hook are broken
Categories
(Bugzilla :: Extensions, defect)
Tracking
()
NEW
People
(Reporter: LpSolit, Unassigned)
References
Details
Original discussion in bug 652663 comment 7:
If your bug_format_comment hook catches a string which belongs to a URL, then the URL is badly formatted due to its conflict with quoteUrls:
http://www.foo.com/PR123 becomes http://www.foo.com/0 if your hook catches PR\d+.
This bug is responsible e.g. for http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52228
| Reporter | ||
Comment 1•14 years ago
|
||
Workaround:
In Extension.pm, first define a _linkify_url() subroutine:
sub bug_format_comment {
my ($self, $args) = @_;
my $safe_protocols = join('|', SAFE_PROTOCOLS);
my $protocol_re = qr/($safe_protocols)/i;
my @regexp = ({ match => qr/\b(${protocol_re}:\/\/[^\s<>\"\0]+[\w\/])/,
replace => \&_linkify_url },
{ .... your other regexps .... });
push(@{$args->{regexes}}, @regexp);
}
sub _linkify_url {
my $args = shift;
my $url = $args->{matches}->[0];
$url = html_quote($url);
return qq{<a href="$url">$url</a>};
}
This will prevent all URLs from being mangled.
Comment 3•10 years ago
|
||
(In reply to Frédéric Buclin from comment #1)
> Workaround:
>
> In Extension.pm, first define a _linkify_url() subroutine:
>
> sub bug_format_comment {
> my ($self, $args) = @_;
> my $safe_protocols = join('|', SAFE_PROTOCOLS);
> my $protocol_re = qr/($safe_protocols)/i;
>
> my @regexp = ({ match => qr/\b(${protocol_re}:\/\/[^\s<>\"\0]+[\w\/])/,
> replace => \&_linkify_url },
> { .... your other regexps .... });
>
> push(@{$args->{regexes}}, @regexp);
> }
>
>
> sub _linkify_url {
> my $args = shift;
> my $url = $args->{matches}->[0];
>
> $url = html_quote($url);
> return qq{<a href="$url">$url</a>};
> }
>
> This will prevent all URLs from being mangled.
Hi, i am not familiar with bugzilla code, could you offer this as a diff format? i not sure which Extension.pm
Flags: needinfo?(LpSolit)
| Reporter | ||
Comment 4•10 years ago
|
||
I cannot write a patch for this because it must be copied in a file which doesn't exist yet. This code must into your own extension.
Flags: needinfo?(LpSolit)
You need to log in
before you can comment on or make changes to this bug.
Description
•