Bug 68347 - Remove \n and (> ) from wiki:[[...]] links

git-svn-id: svn://svn.office.custis.ru/3rdparty/bugzilla.org/trunk@914 6955db30-a419-402b-8a0d-67ecbb4d7f56
master
vfilippov 2010-08-25 13:31:11 +00:00
parent de77fec13d
commit 15a451fa7b
1 changed files with 22 additions and 6 deletions

View File

@ -248,12 +248,28 @@ sub quoteUrls {
if ($custom_proto && %$custom_proto)
{
$text =~ s
~\b($custom_proto_regex):(?:\[\[(.*?)(?:\#(.*?))?\]\]|([^\s<>\#]+)(?:\#([^\s<>\"\#]+))?)
~($tmp = html_quote(&{$custom_proto->{$1}}(trim($2)||$4, trim($2)?trim($3):$5))) &&
($things[$count++] = "<a href=\"$tmp\">$&</a>") &&
("\0\0" . ($count-1) . "\0\0")
~gesox;
my @text = split /\b(($custom_proto_regex):(?:\[\[(.*?)(?:\#(.*?))?\]\]|([^\s<>\#]+)(?:\#([^\s<>\"\#]+))?))/is, $text;
$text = shift @text;
my $link;
while (@text)
{
my ($linktext, $proto, $verb_url, $verb_anchor, $url, $anchor) = splice @text, 0, 6;
if ($verb_url = trim($verb_url))
{
# remove line feeds and reply markers as the comment is already wrapped
s/\n(>\s*)*//gso for $verb_url, $verb_anchor;
$verb_anchor = trim($verb_anchor);
$link = &{$custom_proto->{$proto}}($verb_url, $verb_anchor);
}
else
{
$link = &{$custom_proto->{$proto}}($url, $anchor);
}
$things[$count] = "<a href=\"$link\">$linktext</a>";
$text .= "\0\0$count\0\0";
$text .= shift @text;
$count++;
}
}
# We have to quote now, otherwise the html itself is escaped