Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
bugzilla
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
bugzilla
Commits
d65d0102
Commit
d65d0102
authored
Aug 15, 2013
by
Frédéric Buclin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 105865: Bugzilla should pay attention to linebreaks when linkifying bug IDs in comments
r=dkl a=sgreen
parent
37ce30c4
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
13 deletions
+17
-13
Template.pm
Bugzilla/Template.pm
+17
-13
No files found.
Bugzilla/Template.pm
View file @
d65d0102
...
@@ -160,6 +160,10 @@ sub quoteUrls {
...
@@ -160,6 +160,10 @@ sub quoteUrls {
my
$chr1
=
chr
(
1
);
my
$chr1
=
chr
(
1
);
$text
=~
s/\0/$chr1\0/g
;
$text
=~
s/\0/$chr1\0/g
;
# If the comment is already wrapped, we should ignore newlines when
# looking for matching regexps. Else we should take them into account.
my
$s
=
(
$comment
&&
$comment
->
already_wrapped
)
?
qr/\s/
:
qr/\h/
;
# However, note that adding the title (for buglinks) can affect things
# However, note that adding the title (for buglinks) can affect things
# In particular, attachment matches go before bug titles, so that titles
# In particular, attachment matches go before bug titles, so that titles
# with 'attachment 1' don't double match.
# with 'attachment 1' don't double match.
...
@@ -226,7 +230,7 @@ sub quoteUrls {
...
@@ -226,7 +230,7 @@ sub quoteUrls {
~<
a
href
=\
"mailto:$2\">$1$2</a>~igx;
~<
a
href
=\
"mailto:$2\">$1$2</a>~igx;
# attachment links
# attachment links
$text =~ s~\b(attachment
\s*\#?\s*(\d+)(?:\
s+\[details\])?)
$text =~ s~\b(attachment
$s*\#?$s*(\d+)(?:$
s+\[details\])?)
~($things[$count++] = get_attachment_link($2, $1, $user)) &&
~($things[$count++] = get_attachment_link($2, $1, $user)) &&
("
\
0
\
0
" . ($count-1) . "
\
0
\
0
")
("
\
0
\
0
" . ($count-1) . "
\
0
\
0
")
~egmxi;
~egmxi;
...
@@ -239,43 +243,43 @@ sub quoteUrls {
...
@@ -239,43 +243,43 @@ sub quoteUrls {
# Also, we can't use $bug_re?$comment_re? because that will match the
# Also, we can't use $bug_re?$comment_re? because that will match the
# empty string
# empty string
my $bug_word = template_var('terms')->{bug};
my $bug_word = template_var('terms')->{bug};
my $bug_re = qr/\Q$bug_word\E
\s*\#?\
s*(\d+)/i;
my $bug_re = qr/\Q$bug_word\E
$s*\#?$
s*(\d+)/i;
my $comment_word = template_var('terms')->{comment};
my $comment_word = template_var('terms')->{comment};
my $comment_re = qr/(?:\Q$comment_word\E|comment)
\s*\#?\
s*(\d+)/i;
my $comment_re = qr/(?:\Q$comment_word\E|comment)
$s*\#?$
s*(\d+)/i;
$text =~ s~\b($bug_re(?:
\s*,?\
s*$comment_re)?|$comment_re)
$text =~ s~\b($bug_re(?:
$s*,?$
s*$comment_re)?|$comment_re)
~ # We have several choices. $1 here is the link, and $2-4 are set
~ # We have several choices. $1 here is the link, and $2-4 are set
# depending on which part matched
# depending on which part matched
(defined($2) ? get_bug_link($2, $1, { comment_num => $3, user => $user }) :
(defined($2) ? get_bug_link($2, $1, { comment_num => $3, user => $user }) :
"
<
a
href
=\
"$current_bugurl#c$4\">$1</a>"
)
"
<
a
href
=\
"$current_bugurl#c$4\">$1</a>"
)
~
eg
o
x
;
~
egx
;
# Handle a list of bug ids: bugs 1, #2, 3, 4
# Handle a list of bug ids: bugs 1, #2, 3, 4
# Currently, the only delimiter supported is comma.
# Currently, the only delimiter supported is comma.
# Concluding "and" and "or" are not supported.
# Concluding "and" and "or" are not supported.
my
$bugs_word
=
template_var
(
'terms'
)
->
{
bugs
};
my
$bugs_word
=
template_var
(
'terms'
)
->
{
bugs
};
my
$bugs_re
=
qr/\Q$bugs_word\E
\s*\#?\
s*
my
$bugs_re
=
qr/\Q$bugs_word\E
$s*\#?$
s*
\d+(?:
\s*,\s*\#?\
s*\d+)+/
ix
;
\d+(?:
$s*,$s*\#?$
s*\d+)+/
ix
;
while
(
$text
=~
m/($bugs_re)/g
o
)
{
while
(
$text
=~
m/($bugs_re)/g
)
{
my
$offset
=
$-
[
0
];
my
$offset
=
$-
[
0
];
my
$length
=
$+
[
0
]
-
$-
[
0
];
my
$length
=
$+
[
0
]
-
$-
[
0
];
my
$match
=
$1
;
my
$match
=
$1
;
$match
=~
s/((?:#
\
s*)?(\d+))/get_bug_link($2, $1);/eg
;
$match
=~
s/((?:#
$
s*)?(\d+))/get_bug_link($2, $1);/eg
;
# Replace the old string with the linkified one.
# Replace the old string with the linkified one.
substr
(
$text
,
$offset
,
$length
)
=
$match
;
substr
(
$text
,
$offset
,
$length
)
=
$match
;
}
}
my
$comments_word
=
template_var
(
'terms'
)
->
{
comments
};
my
$comments_word
=
template_var
(
'terms'
)
->
{
comments
};
my
$comments_re
=
qr/(?:comments|\Q$comments_word\E)
\s*\#?\
s*
my
$comments_re
=
qr/(?:comments|\Q$comments_word\E)
$s*\#?$
s*
\d+(?:
\s*,\s*\#?\
s*\d+)+/
ix
;
\d+(?:
$s*,$s*\#?$
s*\d+)+/
ix
;
while
(
$text
=~
m/($comments_re)/g
o
)
{
while
(
$text
=~
m/($comments_re)/g
)
{
my
$offset
=
$-
[
0
];
my
$offset
=
$-
[
0
];
my
$length
=
$+
[
0
]
-
$-
[
0
];
my
$length
=
$+
[
0
]
-
$-
[
0
];
my
$match
=
$1
;
my
$match
=
$1
;
$match
=~
s
|
((?:
#
\
s*)?(\d+))|<a href="$current_bugurl#c$2">$1</a>|g;
$match
=~
s
|
((?:
#
$
s*)?(\d+))|<a href="$current_bugurl#c$2">$1</a>|g;
substr
(
$text
,
$offset
,
$length
)
=
$match
;
substr
(
$text
,
$offset
,
$length
)
=
$match
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment