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
3eb1f9f9
Commit
3eb1f9f9
authored
Oct 28, 2014
by
David Lawrence
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 1059684 - markdown text should not be rendered within a <pre> tag
r=glob,a=glob
parent
bacbb85f
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
53 additions
and
21 deletions
+53
-21
Markdown.pm
Bugzilla/Markdown.pm
+1
-8
User.pm
Bugzilla/User.pm
+14
-0
field.js
js/field.js
+24
-4
process_bug.cgi
process_bug.cgi
+2
-2
global.css
skins/standard/global.css
+5
-1
comment.html.tmpl
template/en/default/bug/comment.html.tmpl
+5
-4
comments.html.tmpl
template/en/default/bug/comments.html.tmpl
+2
-2
No files found.
Bugzilla/Markdown.pm
View file @
3eb1f9f9
...
...
@@ -99,7 +99,7 @@ sub _RunSpanGamut {
$text
=
$self
->
_EncodeAmpsAndAngles
(
$text
);
$text
=
$self
->
_DoItalicsAndBold
(
$text
);
$text
=~
s/
{2,}\n/
<br$self->{empty_element_suffix}\n/g
;
$text
=~
s/
\n/
<br$self->{empty_element_suffix}\n/g
;
return
$text
;
}
...
...
@@ -323,13 +323,6 @@ sub _DoItalicsAndBold {
return
$text
;
}
# Override this function to ignore 'wrap_in_p_tags' from
# the caller and to not generate <p> tags around the output.
sub
_FormParagraphs
{
my
(
$self
,
$text
)
=
@_
;
return
$self
->
SUPER::
_FormParagraphs
(
$text
,
{
wrap_in_p_tags
=>
0
});
}
sub
_DoStrikethroughs
{
my
(
$self
,
$text
)
=
@_
;
...
...
Bugzilla/User.pm
View file @
3eb1f9f9
...
...
@@ -632,6 +632,14 @@ sub is_bug_ignored {
return
(
grep
{
$_
->
{
'id'
}
==
$bug_id
}
@
{
$self
->
bugs_ignored
})
?
1
:
0
;
}
sub
use_markdown
{
my
(
$self
,
$comment
)
=
@_
;
return
Bugzilla
->
feature
(
'markdown'
)
&&
$self
->
settings
->
{
use_markdown
}
->
{
is_enabled
}
&&
$self
->
settings
->
{
use_markdown
}
->
{
value
}
eq
'on'
&&
(
!
defined
$comment
||
$comment
->
is_markdown
);
}
##########################
# Saved Recent Bug Lists #
##########################
...
...
@@ -2623,6 +2631,12 @@ C<string> The current summary of the bug.
Returns true if the user does not want email notifications for the
specified bug ID, else returns false.
=item C<use_markdown>
Returns true if the user has set their preferences to use Markdown
for rendering comments. If an optional C<comment> object is passed
then it returns true if the comment has markdown enabled.
=back
=head2 Saved Recent Bug Lists
...
...
js/field.js
View file @
3eb1f9f9
...
...
@@ -984,18 +984,32 @@ function initDirtyFieldTracking() {
var
last_comment_text
=
''
;
var
last_markdown_cb_value
=
null
;
var
comment_textarea_width
=
null
;
var
comment_textarea_height
=
null
;
function
show_comment_preview
(
bug_id
)
{
function
refresh_markdown_preview
(
bug_id
)
{
if
(
!
YAHOO
.
util
.
Dom
.
hasClass
(
'comment_preview_tab'
,
'active_comment_tab'
))
return
;
show_comment_preview
(
bug_id
,
1
);
}
function
show_comment_preview
(
bug_id
,
refresh
)
{
var
Dom
=
YAHOO
.
util
.
Dom
;
var
comment
=
document
.
getElementById
(
'comment'
);
var
preview
=
document
.
getElementById
(
'comment_preview'
);
var
markdown_cb
=
document
.
getElementById
(
'use_markdown'
);
if
(
!
comment
||
!
preview
)
return
;
if
(
Dom
.
hasClass
(
'comment_preview_tab'
,
'active_comment_tab'
))
return
;
if
(
Dom
.
hasClass
(
'comment_preview_tab'
,
'active_comment_tab'
)
&&
!
refresh
)
return
;
preview
.
style
.
width
=
(
comment
.
clientWidth
-
4
)
+
'px'
;
preview
.
style
.
height
=
comment
.
offsetHeight
+
'px'
;
if
(
!
comment_textarea_width
)
{
comment_textarea_width
=
(
comment
.
clientWidth
-
4
)
+
'px'
;
comment_textarea_height
=
comment
.
offsetHeight
+
'px'
;
}
preview
.
style
.
width
=
comment_textarea_width
;
preview
.
style
.
height
=
comment_textarea_height
;
var
comment_tab
=
document
.
getElementById
(
'comment_tab'
);
Dom
.
addClass
(
comment
,
'bz_default_hidden'
);
...
...
@@ -1029,6 +1043,12 @@ function show_comment_preview(bug_id) {
document
.
getElementById
(
'comment_preview_text'
).
innerHTML
=
data
.
result
.
html
;
Dom
.
addClass
(
'comment_preview_loading'
,
'bz_default_hidden'
);
Dom
.
removeClass
(
'comment_preview_text'
,
'bz_default_hidden'
);
if
(
markdown_cb
.
checked
)
{
Dom
.
removeClass
(
'comment_preview_text'
,
'comment_preview_pre'
);
}
else
{
Dom
.
addClass
(
'comment_preview_text'
,
'comment_preview_pre'
);
}
last_comment_text
=
comment
.
value
;
last_markdown_cb_value
=
markdown_cb
.
checked
;
}
...
...
process_bug.cgi
View file @
3eb1f9f9
...
...
@@ -233,8 +233,8 @@ if (should_set('keywords')) {
$set_all_fields
{
keywords
}
->
{
$action
}
=
$cgi
->
param
(
'keywords'
);
}
if
(
should_set
(
'comment'
))
{
my
$is_markdown
=
(
$user
->
settings
->
{
use_markdown
}
->
{
is_enabled
}
&&
$cgi
->
param
(
'use_markdown'
)
)
?
1
:
0
;
my
$is_markdown
=
(
$user
->
use_markdown
&&
$cgi
->
param
(
'use_markdown'
)
eq
'1'
)
?
1
:
0
;
$set_all_fields
{
comment
}
=
{
body
=>
scalar
$cgi
->
param
(
'comment'
),
...
...
skins/standard/global.css
View file @
3eb1f9f9
...
...
@@ -319,7 +319,7 @@ div#docslinks {
}
/* tbody.file pre is for the Diff view of attachments. */
.bz_comment_text
,
.uneditable_textarea
,
tbody
.file
pre
{
pre
.bz_comment_text
,
.uneditable_textarea
,
tbody
.file
pre
{
font-family
:
monospace
;
white-space
:
pre-wrap
;
}
...
...
@@ -732,6 +732,10 @@ input.required, select.required, span.required_explanation {
width
:
auto
;
}
.comment_preview_pre
{
white-space
:
pre
;
}
#comment_preview_loading
{
font-style
:
italic
;
}
...
...
template/en/default/bug/comment.html.tmpl
View file @
3eb1f9f9
...
...
@@ -32,14 +32,15 @@
<div id="comment_preview" class="bz_default_hidden bz_comment">
<div id="comment_preview_loading" class="bz_default_hidden">Generating Preview...</div>
<div id="comment_preview_error" class="bz_default_hidden"></div>
<
pre id="comment_preview_text" class="bz_comment_text"></pre
>
<
div id="comment_preview_text" class="bz_comment_text"></div
>
</div>
[% END %]
[% IF
feature_enabled('markdown') AND user.settings.use_markdown.value == 'on'
%]
[% IF
user.use_markdown
%]
<div id="comment_markdown">
<input type="checkbox" name="use_markdown" id="use_markdown" value="1"
[% "checked=\"checked\"" IF user.settings.use_markdown.value == 'on' %] >
<input type="checkbox" name="use_markdown"
id="use_markdown" value="1" checked="checked"
onchange="refresh_markdown_preview([% bug.id FILTER none %])">
<label id="use_markdown_label" for="use_markdown">Use Markdown for this [% terms.comment %]</label>
(<a href="page.cgi?id=markdown.html" target="_blank" title="View Markdown Syntax Guide">help</a>)
</div>
...
...
template/en/default/bug/comments.html.tmpl
View file @
3eb1f9f9
...
...
@@ -267,12 +267,12 @@
[%# Don't indent the <pre> block, since then the spaces are displayed in the
# generated HTML
#%]
<
pre
class="bz_comment_text[% " collapsed" IF comment.collapsed %]"
<
[% user.use_markdown(comment) ? "div" : "pre" %]
class="bz_comment_text[% " collapsed" IF comment.collapsed %]"
[% IF mode == "edit" || comment.collapsed %]
id="comment_text_[% comment.count FILTER none %]"
[% END %]>
[%- comment_text FILTER markdown(bug, comment) -%]
</
pre
>
</
[% user.use_markdown(comment) ? "div" : "pre" %]
>
[% Hook.process('a_comment-end', 'bug/comments.html.tmpl') %]
</div>
[% END %]
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